Mercurial > mxe-octave
comparison src/of-communications-2-fixes.patch @ 4199:f7fce04ebafa
temporary fixes for of-communications package
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 31 Aug 2016 15:01:51 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4198:2f1d93109f43 | 4199:f7fce04ebafa |
---|---|
1 diff --git a/src/base-lu.cc b/src/base-lu.cc | |
2 new file mode 100644 | |
3 --- /dev/null | |
4 +++ b/src/base-lu.cc | |
5 @@ -0,0 +1,191 @@ | |
6 +/* | |
7 + | |
8 +Copyright (C) 1996-2015 John W. Eaton | |
9 +Copyright (C) 2009 VZLU Prague | |
10 + | |
11 +This file is part of Octave. | |
12 + | |
13 +Octave is free software; you can redistribute it and/or modify it | |
14 +under the terms of the GNU General Public License as published by the | |
15 +Free Software Foundation; either version 3 of the License, or (at your | |
16 +option) any later version. | |
17 + | |
18 +Octave is distributed in the hope that it will be useful, but WITHOUT | |
19 +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
20 +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
21 +for more details. | |
22 + | |
23 +You should have received a copy of the GNU General Public License | |
24 +along with Octave; see the file COPYING. If not, see | |
25 +<http://www.gnu.org/licenses/>. | |
26 + | |
27 +*/ | |
28 + | |
29 +#ifdef HAVE_CONFIG_H | |
30 +#include <config.h> | |
31 +#endif | |
32 + | |
33 +#include "base-lu.h" | |
34 + | |
35 +template <class lu_type> | |
36 +base_lu<lu_type>::base_lu (const lu_type& l, const lu_type& u, | |
37 + const PermMatrix& p) | |
38 + : a_fact (u), l_fact (l), ipvt (p.transpose ().col_perm_vec ()) | |
39 +{ | |
40 + if (l.columns () != u.rows ()) | |
41 + (*current_liboctave_error_handler) ("lu: dimension mismatch"); | |
42 +} | |
43 + | |
44 +template <class lu_type> | |
45 +bool | |
46 +base_lu <lu_type> :: packed (void) const | |
47 +{ | |
48 + return l_fact.dims () == dim_vector (); | |
49 +} | |
50 + | |
51 +template <class lu_type> | |
52 +void | |
53 +base_lu <lu_type> :: unpack (void) | |
54 +{ | |
55 + if (packed ()) | |
56 + { | |
57 + l_fact = L (); | |
58 + a_fact = U (); // FIXME: sub-optimal | |
59 + ipvt = getp (); | |
60 + } | |
61 +} | |
62 + | |
63 +template <class lu_type> | |
64 +lu_type | |
65 +base_lu <lu_type> :: L (void) const | |
66 +{ | |
67 + if (packed ()) | |
68 + { | |
69 + octave_idx_type a_nr = a_fact.rows (); | |
70 + octave_idx_type a_nc = a_fact.cols (); | |
71 + octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc); | |
72 + | |
73 + lu_type l (a_nr, mn, lu_elt_type (0.0)); | |
74 + | |
75 + for (octave_idx_type i = 0; i < a_nr; i++) | |
76 + { | |
77 + if (i < a_nc) | |
78 + l.xelem (i, i) = 1.0; | |
79 + | |
80 + for (octave_idx_type j = 0; j < (i < a_nc ? i : a_nc); j++) | |
81 + l.xelem (i, j) = a_fact.xelem (i, j); | |
82 + } | |
83 + | |
84 + return l; | |
85 + } | |
86 + else | |
87 + return l_fact; | |
88 +} | |
89 + | |
90 +template <class lu_type> | |
91 +lu_type | |
92 +base_lu <lu_type> :: U (void) const | |
93 +{ | |
94 + if (packed ()) | |
95 + { | |
96 + octave_idx_type a_nr = a_fact.rows (); | |
97 + octave_idx_type a_nc = a_fact.cols (); | |
98 + octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc); | |
99 + | |
100 + lu_type u (mn, a_nc, lu_elt_type (0.0)); | |
101 + | |
102 + for (octave_idx_type i = 0; i < mn; i++) | |
103 + { | |
104 + for (octave_idx_type j = i; j < a_nc; j++) | |
105 + u.xelem (i, j) = a_fact.xelem (i, j); | |
106 + } | |
107 + | |
108 + return u; | |
109 + } | |
110 + else | |
111 + return a_fact; | |
112 +} | |
113 + | |
114 +template <class lu_type> | |
115 +lu_type | |
116 +base_lu <lu_type> :: Y (void) const | |
117 +{ | |
118 + if (! packed ()) | |
119 + (*current_liboctave_error_handler) | |
120 + ("lu: Y () not implemented for unpacked form"); | |
121 + return a_fact; | |
122 +} | |
123 + | |
124 +template <class lu_type> | |
125 +Array<octave_idx_type> | |
126 +base_lu <lu_type> :: getp (void) const | |
127 +{ | |
128 + if (packed ()) | |
129 + { | |
130 + octave_idx_type a_nr = a_fact.rows (); | |
131 + | |
132 + Array<octave_idx_type> pvt (dim_vector (a_nr, 1)); | |
133 + | |
134 + for (octave_idx_type i = 0; i < a_nr; i++) | |
135 + pvt.xelem (i) = i; | |
136 + | |
137 + for (octave_idx_type i = 0; i < ipvt.length (); i++) | |
138 + { | |
139 + octave_idx_type k = ipvt.xelem (i); | |
140 + | |
141 + if (k != i) | |
142 + { | |
143 + octave_idx_type tmp = pvt.xelem (k); | |
144 + pvt.xelem (k) = pvt.xelem (i); | |
145 + pvt.xelem (i) = tmp; | |
146 + } | |
147 + } | |
148 + | |
149 + return pvt; | |
150 + } | |
151 + else | |
152 + return ipvt; | |
153 +} | |
154 + | |
155 +template <class lu_type> | |
156 +PermMatrix | |
157 +base_lu <lu_type> :: P (void) const | |
158 +{ | |
159 + return PermMatrix (getp (), false); | |
160 +} | |
161 + | |
162 +template <class lu_type> | |
163 +ColumnVector | |
164 +base_lu <lu_type> :: P_vec (void) const | |
165 +{ | |
166 + octave_idx_type a_nr = a_fact.rows (); | |
167 + | |
168 + ColumnVector p (a_nr); | |
169 + | |
170 + Array<octave_idx_type> pvt = getp (); | |
171 + | |
172 + for (octave_idx_type i = 0; i < a_nr; i++) | |
173 + p.xelem (i) = static_cast<double> (pvt.xelem (i) + 1); | |
174 + | |
175 + return p; | |
176 +} | |
177 + | |
178 +template <class lu_type> | |
179 +bool | |
180 +base_lu<lu_type>::regular (void) const | |
181 +{ | |
182 + bool retval = true; | |
183 + | |
184 + octave_idx_type k = std::min (a_fact.rows (), a_fact.columns ()); | |
185 + | |
186 + for (octave_idx_type i = 0; i < k; i++) | |
187 + { | |
188 + if (a_fact(i, i) == lu_elt_type ()) | |
189 + { | |
190 + retval = false; | |
191 + break; | |
192 + } | |
193 + } | |
194 + | |
195 + return retval; | |
196 +} | |
197 diff --git a/src/base-lu.h b/src/base-lu.h | |
198 new file mode 100644 | |
199 --- /dev/null | |
200 +++ b/src/base-lu.h | |
201 @@ -0,0 +1,87 @@ | |
202 +/* | |
203 + | |
204 +Copyright (C) 1996-2015 John W. Eaton | |
205 +Copyright (C) 2009 VZLU Prague | |
206 + | |
207 +This file is part of Octave. | |
208 + | |
209 +Octave is free software; you can redistribute it and/or modify it | |
210 +under the terms of the GNU General Public License as published by the | |
211 +Free Software Foundation; either version 3 of the License, or (at your | |
212 +option) any later version. | |
213 + | |
214 +Octave is distributed in the hope that it will be useful, but WITHOUT | |
215 +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
216 +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
217 +for more details. | |
218 + | |
219 +You should have received a copy of the GNU General Public License | |
220 +along with Octave; see the file COPYING. If not, see | |
221 +<http://www.gnu.org/licenses/>. | |
222 + | |
223 +*/ | |
224 + | |
225 +#if !defined (octave_base_lu_h) | |
226 +#define octave_base_lu_h 1 | |
227 + | |
228 +#include "MArray.h" | |
229 +#include "dColVector.h" | |
230 +#include "PermMatrix.h" | |
231 + | |
232 +template <class lu_type> | |
233 +class | |
234 +base_lu | |
235 +{ | |
236 +public: | |
237 + | |
238 + typedef typename lu_type::element_type lu_elt_type; | |
239 + | |
240 + base_lu (void) | |
241 + : a_fact (), l_fact (), ipvt () { } | |
242 + | |
243 + base_lu (const base_lu& a) | |
244 + : a_fact (a.a_fact), l_fact (a.l_fact), ipvt (a.ipvt) { } | |
245 + | |
246 + base_lu (const lu_type& l, const lu_type& u, | |
247 + const PermMatrix& p); | |
248 + | |
249 + base_lu& operator = (const base_lu& a) | |
250 + { | |
251 + if (this != &a) | |
252 + { | |
253 + a_fact = a.a_fact; | |
254 + l_fact = a.l_fact; | |
255 + ipvt = a.ipvt; | |
256 + } | |
257 + return *this; | |
258 + } | |
259 + | |
260 + virtual ~base_lu (void) { } | |
261 + | |
262 + bool packed (void) const; | |
263 + | |
264 + void unpack (void); | |
265 + | |
266 + lu_type L (void) const; | |
267 + | |
268 + lu_type U (void) const; | |
269 + | |
270 + lu_type Y (void) const; | |
271 + | |
272 + PermMatrix P (void) const; | |
273 + | |
274 + ColumnVector P_vec (void) const; | |
275 + | |
276 + bool regular (void) const; | |
277 + | |
278 +protected: | |
279 + | |
280 + Array<octave_idx_type> getp (void) const; | |
281 + | |
282 + lu_type a_fact; | |
283 + lu_type l_fact; | |
284 + | |
285 + Array<octave_idx_type> ipvt; | |
286 +}; | |
287 + | |
288 +#endif | |
289 diff --git a/src/galois-ops.h b/src/galois-ops.h | |
290 --- a/src/galois-ops.h | |
291 +++ b/src/galois-ops.h | |
292 @@ -21,6 +21,32 @@ | |
293 #if !defined (galois_octave_ops_h) | |
294 #define galois_octave_ops_h 1 | |
295 | |
296 +#if ! defined (CAST_BINOP_ARGS) | |
297 +# define CAST_BINOP_ARGS(t1, t2) \ | |
298 + t1 v1 = dynamic_cast<t1> (a1); \ | |
299 + t2 v2 = dynamic_cast<t2> (a2) | |
300 +#endif | |
301 + | |
302 +#if ! defined (CAST_UNOP_ARG) | |
303 +# define CAST_UNOP_ARG(t) \ | |
304 + t v = dynamic_cast<t> (a) | |
305 +#endif | |
306 + | |
307 +#if ! defined (BINOPDECL) | |
308 +# define BINOPDECL(name, a1, a2) \ | |
309 + static octave_value \ | |
310 + CONCAT2(oct_binop_, name) (const octave_base_value& a1, \ | |
311 + const octave_base_value& a2) | |
312 +#endif | |
313 + | |
314 +#if ! defined (CATOPDECL) | |
315 +# define CATOPDECL(name, a1, a2) \ | |
316 + static octave_value \ | |
317 + CONCAT2(oct_catop_, name) (octave_base_value& a1, \ | |
318 + const octave_base_value& a2, \ | |
319 + const Array<octave_idx_type>& ra_idx) | |
320 +#endif | |
321 + | |
322 // Override the operator and function definition defines from Octave | |
323 | |
324 #define DEFBINOP_OP_G(name, t1, t2, op) \ | |
325 diff --git a/src/galois.cc b/src/galois.cc | |
326 --- a/src/galois.cc | |
327 +++ b/src/galois.cc | |
328 @@ -27,7 +27,7 @@ | |
329 #include "galoisfield.h" | |
330 #include "galois-def.h" | |
331 | |
332 -#include <octave/base-lu.cc> | |
333 +#include "base-lu.cc" | |
334 | |
335 galois_field_list stored_galois_fields; | |
336 | |
337 diff --git a/src/galois.h b/src/galois.h | |
338 --- a/src/galois.h | |
339 +++ b/src/galois.h | |
340 @@ -22,10 +22,10 @@ | |
341 #define octave_galois_int_h 1 | |
342 | |
343 #include <octave/config.h> | |
344 -#include <octave/base-lu.h> | |
345 #include <octave/mx-base.h> | |
346 | |
347 #include "galoisfield.h" | |
348 +#include "base-lu.h" | |
349 | |
350 typedef void (*solve_singularity_handler) (double rcond); | |
351 | |
352 diff --git a/src/ov-galois.cc b/src/ov-galois.cc | |
353 --- a/src/ov-galois.cc | |
354 +++ b/src/ov-galois.cc | |
355 @@ -24,7 +24,6 @@ | |
356 #include <octave/byte-swap.h> | |
357 #include <octave/gripes.h> | |
358 #include <octave/lo-ieee.h> | |
359 -#include <octave/oct-hdf5.h> | |
360 #include <octave/oct-locbuf.h> | |
361 #include <octave/oct-obj.h> | |
362 #include <octave/ov.h> | |
363 @@ -35,6 +34,22 @@ | |
364 #include "galois.h" | |
365 #include "ov-galois.h" | |
366 | |
367 +#if defined (HAVE_HDF5) | |
368 +# if defined (HAVE_HDF5_H) | |
369 +# include <hdf5.h> | |
370 +# endif | |
371 +# include "oct-hdf5-types.h" | |
372 +# if defined (OCTAVE_ENABLE_64) | |
373 +# define H5T_NATIVE_IDX H5T_NATIVE_INT64 | |
374 +# else | |
375 +# define H5T_NATIVE_IDX H5T_NATIVE_INT | |
376 +# endif | |
377 +#endif | |
378 + | |
379 +#if ! defined (X_CAST) | |
380 +# define X_CAST(T, E) (T) (E) | |
381 +#endif | |
382 + | |
383 #if defined (DEFINE_OCTAVE_ALLOCATOR) | |
384 DEFINE_OCTAVE_ALLOCATOR (octave_galois); | |
385 #endif | |
386 diff --git a/src/syndtable.cc b/src/syndtable.cc | |
387 --- a/src/syndtable.cc | |
388 +++ b/src/syndtable.cc | |
389 @@ -20,8 +20,8 @@ | |
390 | |
391 #include <octave/oct.h> | |
392 | |
393 -#define COL_MAJ(N) (N / (SIZEOF_INT << 3)) | |
394 -#define COL_MIN(N) (N % (SIZEOF_INT << 3)) | |
395 +#define COL_MAJ(N) (N / (sizeof (int) << 3)) | |
396 +#define COL_MIN(N) (N % (sizeof (int) << 3)) | |
397 | |
398 Array<int> | |
399 get_errs (const int& nmin, const int& nmax, const int &nerrs) |