Mercurial > mxe-octave
annotate src/of-communications-5-fixes.patch @ 4733:1ecb1e67eaa1
* src/src-msys-dos2unix.mk: update checksum
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Sat, 09 Jun 2018 10:13:46 -0400 |
parents | 00e61c4a5657 |
children |
rev | line source |
---|---|
4653
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 diff -uNr a/src/base-lu.cc b/src/base-lu.cc |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 --- a/src/base-lu.cc 2018-04-09 13:25:42.884981069 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3 +++ b/src/base-lu.cc 2018-04-09 13:53:52.501958203 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 @@ -125,7 +125,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 for (octave_idx_type i = 0; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 pvt.xelem (i) = i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 - for (octave_idx_type i = 0; i < ipvt.length (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 + for (octave_idx_type i = 0; i < ipvt.numel (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 octave_idx_type k = ipvt.xelem (i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 diff -uNr a/src/base-lu.cc~ b/src/base-lu.cc~ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 --- a/src/base-lu.cc~ 1969-12-31 19:00:00.000000000 -0500 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 +++ b/src/base-lu.cc~ 2018-04-09 13:26:27.478896947 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 @@ -0,0 +1,187 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 +Copyright (C) 1996-2015 John W. Eaton |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 +Copyright (C) 2009 VZLU Prague |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 +This file is part of Octave. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 +Octave is free software; you can redistribute it and/or modify it |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 +under the terms of the GNU General Public License as published by the |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 +Free Software Foundation; either version 3 of the License, or (at your |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 +option) any later version. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 +Octave is distributed in the hope that it will be useful, but WITHOUT |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 +for more details. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 +You should have received a copy of the GNU General Public License |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 +along with Octave; see the file COPYING. If not, see |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 +<http://www.gnu.org/licenses/>. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 +#include "base-lu.h" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 +template <class lu_type> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 +base_lu<lu_type>::base_lu (const lu_type& l, const lu_type& u, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 + const PermMatrix& p) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 + : a_fact (u), l_fact (l), ipvt (p.transpose ().col_perm_vec ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 + if (l.columns () != u.rows ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 + (*current_liboctave_error_handler) ("lu: dimension mismatch"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 +template <class lu_type> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 +bool |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 +base_lu <lu_type> :: packed (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 + return l_fact.dims () == dim_vector (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 +template <class lu_type> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 +void |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 +base_lu <lu_type> :: unpack (void) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 + if (packed ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 + l_fact = L (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 + a_fact = U (); // FIXME: sub-optimal |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 + ipvt = getp (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 +template <class lu_type> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 +lu_type |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 +base_lu <lu_type> :: L (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 + if (packed ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 + octave_idx_type a_nr = a_fact.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 + octave_idx_type a_nc = a_fact.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 + octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 + lu_type l (a_nr, mn, lu_elt_type (0.0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 + for (octave_idx_type i = 0; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 + if (i < a_nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 + l.xelem (i, i) = 1.0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 + for (octave_idx_type j = 0; j < (i < a_nc ? i : a_nc); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 + l.xelem (i, j) = a_fact.xelem (i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 + return l; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 + return l_fact; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 +template <class lu_type> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 +lu_type |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 +base_lu <lu_type> :: U (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 + if (packed ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 + octave_idx_type a_nr = a_fact.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 + octave_idx_type a_nc = a_fact.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 + octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 + lu_type u (mn, a_nc, lu_elt_type (0.0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 + for (octave_idx_type i = 0; i < mn; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 + for (octave_idx_type j = i; j < a_nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 + u.xelem (i, j) = a_fact.xelem (i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
114 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 + return u; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 + return a_fact; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 +template <class lu_type> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 +lu_type |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 +base_lu <lu_type> :: Y (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 + if (! packed ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 + (*current_liboctave_error_handler) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 + ("lu: Y () not implemented for unpacked form"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 + return a_fact; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 +template <class lu_type> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 +Array<octave_idx_type> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 +base_lu <lu_type> :: getp (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 + if (packed ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 + octave_idx_type a_nr = a_fact.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 + Array<octave_idx_type> pvt (dim_vector (a_nr, 1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 + for (octave_idx_type i = 0; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
142 + pvt.xelem (i) = i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
144 + for (octave_idx_type i = 0; i < ipvt.length (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 + octave_idx_type k = ipvt.xelem (i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
148 + if (k != i) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 + octave_idx_type tmp = pvt.xelem (k); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 + pvt.xelem (k) = pvt.xelem (i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 + pvt.xelem (i) = tmp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 + return pvt; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 + return ipvt; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
160 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 +template <class lu_type> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
163 +PermMatrix |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 +base_lu <lu_type> :: P (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 + return PermMatrix (getp (), false); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 +template <class lu_type> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 +ColumnVector |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 +base_lu <lu_type> :: P_vec (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 + octave_idx_type a_nr = a_fact.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
174 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 + ColumnVector p (a_nr); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
176 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 + Array<octave_idx_type> pvt = getp (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 + for (octave_idx_type i = 0; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 + p.xelem (i) = static_cast<double> (pvt.xelem (i) + 1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
181 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 + return p; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
184 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
185 +template <class lu_type> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
186 +bool |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
187 +base_lu<lu_type>::regular (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 + bool retval = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
191 + octave_idx_type k = std::min (a_fact.rows (), a_fact.columns ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 + for (octave_idx_type i = 0; i < k; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 + if (a_fact(i, i) == lu_elt_type ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 + retval = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
204 diff -uNr a/src/cyclgen.cc b/src/cyclgen.cc |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 --- a/src/cyclgen.cc 2015-04-04 12:28:43.942510204 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 +++ b/src/cyclgen.cc 2018-04-09 13:51:41.852070262 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 @@ -29,7 +29,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 const Array<int>& x, const int& n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
210 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 - int x_len = x.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 + int x_len = x.numel (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 Array<int> si (dim_vector (n, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 Array<int> y (dim_vector (x_len, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 diff -uNr a/src/cyclgen.cc~ b/src/cyclgen.cc~ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 --- a/src/cyclgen.cc~ 1969-12-31 19:00:00.000000000 -0500 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 +++ b/src/cyclgen.cc~ 2015-04-04 12:28:43.942510204 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 @@ -0,0 +1,278 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 +//Copyright (C) 2003 David Bateman |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 +// This program is free software; you can redistribute it and/or |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 +// modify it under the terms of the GNU General Public License as |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
224 +// published by the Free Software Foundation; either version 3 of the |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 +// License, or (at your option) any later version. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
226 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
227 +// This program is distributed in the hope that it will be useful, but |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
228 +// WITHOUT ANY WARRANTY; without even the implied warranty of |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
229 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 +// General Public License for more details. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 +// You should have received a copy of the GNU General Public License |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 +// along with this program; if not, see |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 +// <http://www.gnu.org/licenses/>. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
235 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
236 +// In addition to the terms of the GPL, you are permitted to link this |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 +// program with any Open Source program, as defined by the Open Source |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 +// Initiative (www.opensource.org) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 +#include <string> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 +#include <octave/oct.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 +// A simplified version of the filter function for specific lengths of a and b |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 +// in the Galois field GF(2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 +Array<int> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 +filter_gf2 (const Array<int>& b, const Array<int>& a, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 + const Array<int>& x, const int& n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
249 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
251 + int x_len = x.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 + Array<int> si (dim_vector (n, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 + Array<int> y (dim_vector (x_len, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 + for (int i = 0; i < x_len; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
257 + y(i) = si(0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 + if (b(0) && x(i)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 + y(i) ^= 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 + for (int j = 0; j < n - 1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
263 + si(j) = si(j+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 + if (a(j+1) && y(i)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 + si(j) ^= 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
266 + if (b(j+1) && x(i)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
267 + si(j) ^= 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
268 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
269 + si(n-1) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
270 + if (a(n) && y(i)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 + si(n-1) ^= 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
272 + if (b(n) && x(i)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
273 + si(n-1) ^= 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
274 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
275 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
276 + return y; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
277 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 +// Cyclic polynomial is irreducible. I.E. it divides into x^n-1 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
280 +// without remainder There must surely be an easier way of doing this |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 +// as the polynomials are over GF(2). |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 +static bool |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 +do_is_cyclic_polynomial (const Array<int>& a, const int& n, const int& m) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
285 + Array<int> y (dim_vector (n+1, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
286 + Array<int> x (dim_vector (n-m+2, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 + y(0) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
288 + y(n) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
289 + x(0) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
290 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
291 + Array<int> b = filter_gf2 (y, a, x, n); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
292 + b.resize (dim_vector (n+1, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
293 + Array<int> p (dim_vector (m+1, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
294 + p(0) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
295 + Array<int> q = filter_gf2 (a, p, b, m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
296 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
297 + for (int i = 0; i < n+1; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 + if (y(i) ^ q(i)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
299 + return false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
300 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 + return true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
302 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
303 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 +DEFUN_DLD (cyclgen, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
305 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
306 +@deftypefn {Loadable Function} {@var{h} =} cyclgen (@var{n}, @var{p})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
307 +@deftypefnx {Loadable Function} {@var{h} =} cyclgen (@var{n}, @var{p}, @var{typ})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
308 +@deftypefnx {Loadable Function} {[@var{h}, @var{g}] =} cyclgen (@dots{})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
309 +@deftypefnx {Loadable Function} {[@var{h}, @var{g}, @var{k}] =} cyclgen (@dots{})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
310 +Produce the parity check and generator matrix of a cyclic code. The parity\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
311 +check matrix is returned as a @var{m} by @var{n} matrix, representing the\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
312 +[@var{n},@var{k}] cyclic code. @var{m} is the order of the generator\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 +polynomial @var{p} and the message length @var{k} is given by\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
314 +@code{@var{n} - @var{m}}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
315 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 +The generator polynomial can either be a vector of ones and zeros,\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
317 +and length @var{m} representing,\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
318 +@tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
319 +$$ p_0 + p_1 x + p_2 x^2 + \\cdots + p_m x^{m-1} $$\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 +@end tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
321 +@ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
322 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
323 +@example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
324 +@var{p}(1) + @var{p}(2) * x + @var{p}(3) * x^2 + ... + @var{p}(@var{m}) * x^(m-1)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
325 +@end example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
326 +@end ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
328 +The terms of the polynomial are stored least-significant term first.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
329 +Alternatively, @var{p} can be an integer representation of the same\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
330 +polynomial.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
331 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
332 +The form of the parity check matrix is determined by @var{typ}. If\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
333 +@var{typ} is 'system', a systematic parity check matrix is produced. If\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
334 +@var{typ} is 'nosys' and non-systematic parity check matrix is produced.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
335 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
336 +If requested @code{cyclgen} also returns the @var{k} by @var{n} generator\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 +matrix @var{g}.\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
338 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
339 +@seealso{hammgen, gen2par, cyclpoly}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
340 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
341 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
342 + octave_value_list retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
343 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
344 + unsigned long long p = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
345 + int n, m, k, mm; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
346 + bool system = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
347 + Array<int> pp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
348 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
349 + if (nargin < 2 || nargin > 3) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
350 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
351 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
352 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
353 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
354 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
355 + n = args(0).int_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
356 + m = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
357 + while (n > (1<<(m+1))) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
358 + m++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
359 + pp.resize (dim_vector (n+1, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
360 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
361 + if (args(1).is_scalar_type ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
362 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
363 + p = (unsigned long long)(args(1).int_value ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
364 + mm = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
365 + while (p > ((unsigned long long)1<<(mm+1))) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
366 + mm++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
367 + for (int i = 0; i < mm+1; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
368 + pp(i) = (p & (1<<i) ? 1 : 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
369 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
370 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
371 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
372 + Matrix tmp = args(1).matrix_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
373 + if ((tmp.rows () != 1) && (tmp.columns () != 1)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
374 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
375 + error ("cyclgen: generator polynomial must be a vector"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
376 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
377 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
378 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
379 + if (tmp.rows () == 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
380 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
381 + mm = tmp.columns (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
382 + for (int j = 0; j < mm; j++) { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
383 + if (tmp(0, j) == 1) { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
384 + p |= ((unsigned long long)1 << j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
385 + pp(j) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
386 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
387 + else if (tmp(0, j) != 0) { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
388 + error ("cyclgen: illegal generator polynomial"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
389 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
390 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
391 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
392 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
393 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
394 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
395 + mm = tmp.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
396 + for (int i = 0; i < mm; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
397 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
398 + if (tmp(i, 0) == 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
399 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
400 + p |= ((unsigned long long)1 << i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
401 + pp(i) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
402 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
403 + else if (tmp(i, 0) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
404 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
405 + error ("cyclgen: illegal generator polynomial"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
406 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
407 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
408 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
409 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
410 + mm = mm - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
411 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
412 + k = n - mm; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
413 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
414 + if (nargin > 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
415 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
416 + if (args(2).is_string ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
417 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
418 + std::string s_arg = args(2).string_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
419 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
420 + if (s_arg == "system") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
421 + system = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 + else if (s_arg == "nosys") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
423 + system = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
424 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
425 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
426 + error ("cyclgen: illegal argument"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
427 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
428 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
429 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
430 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
431 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
432 + error ("cyclgen: illegal argument"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
433 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
434 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
435 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
436 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
437 + // Haven't implemented this since I'm not sure what matlab wants here |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
438 + if (!system) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
439 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
440 + error ("cyclgen: non-systematic generator matrices not implemented"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
441 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
442 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
443 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
444 + if (!do_is_cyclic_polynomial (pp, n, mm)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
445 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
446 + error ("cyclgen: generator polynomial does not produce cyclic code"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
447 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
448 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
449 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
450 + unsigned long long mask = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
451 + unsigned long long *alpha_to = |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
452 + (unsigned long long *)malloc (sizeof (unsigned long long) * n); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
453 + for (int i = 0; i < n; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
454 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
455 + alpha_to[i] = mask; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
456 + mask <<= 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
457 + if (mask & ((unsigned long long)1<<mm)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
458 + mask ^= p; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
459 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
460 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
461 + Matrix parity (mm, n, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
462 + for (int i = 0; i < n; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
463 + for (int j = 0; j < mm; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
464 + if (alpha_to[i] & ((unsigned long long)1<<j)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
465 + parity(j, i) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
466 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
467 + free (alpha_to); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
468 + retval(0) = octave_value (parity); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
469 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
470 + if (nargout > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
471 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
472 + Matrix generator (k, n, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
473 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
474 + for (int i = 0; i < (int)k; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
475 + for (int j = 0; j < (int)mm; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
476 + generator(i, j) = parity(j, i+mm); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
477 + for (int i = 0; i < (int)k; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
478 + generator(i, i+mm) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
479 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
480 + retval(1) = octave_value (generator); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
481 + retval(2) = octave_value ((double)k); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
482 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
483 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
484 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
485 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
486 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
487 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
488 +%!error cyclgen () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
489 +%!error cyclgen (1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
490 +%!error cyclgen (1, 2, 3, 4) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
491 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
492 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
493 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
494 +;;; Local Variables: *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
495 +;;; mode: C++ *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
496 +;;; End: *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
497 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
498 diff -uNr a/src/cyclpoly.cc b/src/cyclpoly.cc |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
499 --- a/src/cyclpoly.cc 2015-04-04 12:28:43.942510204 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
500 +++ b/src/cyclpoly.cc 2018-04-09 13:52:48.344959602 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
501 @@ -38,7 +38,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
502 const Array<int>& x, const int& n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
503 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
504 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
505 - int x_len = x.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
506 + int x_len = x.numel (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
507 Array<int> si (dim_vector (n, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
508 Array<int> y (dim_vector (x_len, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
509 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
510 @@ -217,8 +217,8 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
511 for (unsigned long long i = (1UL<<m)+1; i < (1UL<<(1+m)); i+=2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
512 if (do_is_cyclic_polynomial (i, n, m)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
513 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
514 - cyclic_polys.resize (cyclic_polys.length ()+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
515 - cyclic_polys(cyclic_polys.length ()-1) = (double)i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
516 + cyclic_polys.resize (cyclic_polys.numel ()+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
517 + cyclic_polys(cyclic_polys.numel ()-1) = (double)i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
518 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
519 break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
520 case CYCLIC_POLY_L: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
521 @@ -233,8 +233,8 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
522 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
523 if (do_is_cyclic_polynomial (i, n, m)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
524 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
525 - cyclic_polys.resize (cyclic_polys.length ()+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
526 - cyclic_polys(cyclic_polys.length ()-1) = (double)i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
527 + cyclic_polys.resize (cyclic_polys.numel ()+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
528 + cyclic_polys(cyclic_polys.numel ()-1) = (double)i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
529 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
530 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
531 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
532 @@ -244,7 +244,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
533 break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
534 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
535 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 - if (cyclic_polys.length () == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
537 + if (cyclic_polys.numel () == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
538 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 octave_stdout << |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
540 "cyclpoly: no generator polynomial statifies constraints" << std::endl; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
541 @@ -254,8 +254,8 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
542 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
543 if (polyrep) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
544 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
545 - Matrix polys (cyclic_polys.length (), m+1, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
546 - for (int i = 0 ; i < cyclic_polys.length (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
547 + Matrix polys (cyclic_polys.numel (), m+1, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
548 + for (int i = 0 ; i < cyclic_polys.numel (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 for (int j = 0; j < m+1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
550 if ((unsigned long long)cyclic_polys(i) & (1<<j)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 polys(i, j) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
552 diff -uNr a/src/cyclpoly.cc~ b/src/cyclpoly.cc~ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
553 --- a/src/cyclpoly.cc~ 1969-12-31 19:00:00.000000000 -0500 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
554 +++ b/src/cyclpoly.cc~ 2018-04-09 13:52:05.442966638 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
555 @@ -0,0 +1,282 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
556 +//Copyright (C) 2003 David Bateman |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
557 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
558 +// This program is free software; you can redistribute it and/or |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
559 +// modify it under the terms of the GNU General Public License as |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
560 +// published by the Free Software Foundation; either version 3 of the |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
561 +// License, or (at your option) any later version. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
562 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
563 +// This program is distributed in the hope that it will be useful, but |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
564 +// WITHOUT ANY WARRANTY; without even the implied warranty of |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
565 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
566 +// General Public License for more details. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
567 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
568 +// You should have received a copy of the GNU General Public License |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
569 +// along with this program; if not, see |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
570 +// <http://www.gnu.org/licenses/>. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
571 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
572 +// In addition to the terms of the GPL, you are permitted to link this |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
573 +// program with any Open Source program, as defined by the Open Source |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
574 +// Initiative (www.opensource.org) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
575 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
576 +#include <iostream> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
577 +#include <string> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
578 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
579 +#include <octave/oct.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
580 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
581 +enum cyclic_poly_type |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
582 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
583 + CYCLIC_POLY_MIN=0, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
584 + CYCLIC_POLY_MAX, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
585 + CYCLIC_POLY_ALL, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
586 + CYCLIC_POLY_L |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
587 +}; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
588 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
589 +// A simplified version of the filter function for specific lengths of |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
590 +// a and b in the Galois field GF(2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
591 +Array<int> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
592 +filter_gf2 (const Array<int>& b, const Array<int>& a, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
593 + const Array<int>& x, const int& n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
594 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
595 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
596 + int x_len = x.numel (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
597 + Array<int> si (dim_vector (n, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
598 + Array<int> y (dim_vector (x_len, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
599 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
600 + for (int i = 0; i < x_len; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
601 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
602 + y(i) = si(0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
603 + if (b(0) && x(i)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
604 + y(i) ^= 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
605 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
606 + for (int j = 0; j < n - 1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
607 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
608 + si(j) = si(j+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
609 + if (a(j+1) && y(i)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
610 + si(j) ^= 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
611 + if (b(j+1) && x(i)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
612 + si(j) ^= 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
613 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
614 + si(n-1) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
615 + if (a(n) && y(i)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
616 + si(n-1) ^= 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
617 + if (b(n) && x(i)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
618 + si(n-1) ^= 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
619 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
620 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
621 + return y; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
622 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
623 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
624 +// Cyclic polynomial is irreducible. I.E. it divides into x^n-1 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
625 +// without remainder There must surely be an easier way of doing this |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
626 +// as the polynomials are over GF(2). |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
627 +static bool |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
628 +do_is_cyclic_polynomial (const unsigned long long& a1, const int& n, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
629 + const int& m) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
630 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
631 + Array<int> a (dim_vector (n+1, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
632 + Array<int> y (dim_vector (n+1, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
633 + Array<int> x (dim_vector (n-m+2, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
634 + y(0) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
635 + y(n) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
636 + x(0) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
637 + for (int i=0; i < m+1; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
638 + a(i) = (a1 & (1UL << i) ? 1 : 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
639 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
640 + Array<int> b = filter_gf2 (y, a, x, n); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
641 + b.resize(dim_vector (n+1, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
642 + Array<int> p (dim_vector (m+1, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
643 + p(0) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
644 + Array<int> q = filter_gf2 (a, p, b, m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
645 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
646 + for (int i=0; i < n+1; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
647 + if (y(i) ^ q(i)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
648 + return false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
649 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
650 + return true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
651 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
652 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
653 +DEFUN_DLD (cyclpoly, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
654 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
655 +@deftypefn {Loadable Function} {@var{y} =} cyclpoly (@var{n}, @var{k})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
656 +@deftypefnx {Loadable Function} {@var{y} =} cyclpoly (@var{n}, @var{k}, @var{opt})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
657 +@deftypefnx {Loadable Function} {@var{y} =} cyclpoly (@var{n}, @var{k}, @var{opt}, @var{rep})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
658 +This function returns the cyclic generator polynomials of the code\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
659 +[@var{n},@var{k}]. By default the polynomial with the smallest weight\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
660 +is returned. However this behavior can be overridden with the @var{opt}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
661 +flag. Valid values of @var{opt} are:\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
662 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
663 +@table @asis\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
664 +@item @code{\"all\"}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
665 +Returns all of the polynomials of the code [@var{n},@var{k}]\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
666 +@item @code{\"min\"}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
667 +Returns the polynomial of minimum weight of the code [@var{n},@var{k}]\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
668 +@item @code{\"max\"}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
669 +Returns the polynomial of the maximum weight of the code [@var{n},@var{k}]\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
670 +@item @var{l}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
671 +Returns the polynomials having exactly the weight @var{l}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
672 +@end table\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
673 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
674 +The polynomials are returns as row-vectors in the variable @var{y}. Each\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
675 +row of @var{y} represents a polynomial with the least-significant term\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
676 +first. The polynomials can be returned with an integer representation\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
677 +if @var{rep} is @code{\"integer\"}. The default behavior is given if @var{rep}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
678 +is @code{\"polynomial\"}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
679 +@seealso{gf, isprimitive}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
680 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
681 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
682 + octave_value retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
683 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
684 + bool polyrep = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
685 + enum cyclic_poly_type type = CYCLIC_POLY_MIN; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
686 + RowVector cyclic_polys; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
687 + int l=0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
688 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
689 + if (nargin < 2 || nargin > 4) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
690 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
691 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
692 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
693 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
694 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
695 + int n = args(0).int_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
696 + int k = args(1).int_value ();; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
697 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
698 + if (n < 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
699 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
700 + error ("cyclpoly: n must be 1 or greater"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
701 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
702 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
703 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
704 + if (n <= k) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
705 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
706 + error ("cyclpoly: k must be less than n"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
707 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
708 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
709 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
710 + for (int i = 2; i < nargin; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
711 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
712 + if (args(i).is_scalar_type ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
713 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
714 + l = args(i).int_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
715 + type = CYCLIC_POLY_L; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
716 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
717 + else if (args(i).is_string ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
718 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
719 + std::string s_arg = args(i).string_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
720 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
721 + if (s_arg == "integer") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
722 + polyrep = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
723 + else if (s_arg == "polynomial") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
724 + polyrep = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
725 + else if (s_arg == "min") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
726 + type = CYCLIC_POLY_MIN; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
727 + else if (s_arg == "max") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
728 + type = CYCLIC_POLY_MAX; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
729 + else if (s_arg == "all") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
730 + type = CYCLIC_POLY_ALL; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
731 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
732 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
733 + error ("cyclpoly: invalid argument"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
734 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
735 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
736 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
737 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
738 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
739 + error ("cyclpoly: incorrect argument type"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
740 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
741 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
742 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
743 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
744 + int m = n - k; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
745 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
746 + // Matlab code seems to think that 1+x+x^3 is of larger weight than |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
747 + // 1+x^2+x^3. So for matlab compatiability the list of polynomials |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
748 + // should be reversed by replacing "i+=2" with "i-=2" and visa-versa. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
749 + // Thats not going to happen!!! |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
750 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
751 + switch (type) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
752 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
753 + case CYCLIC_POLY_MIN: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
754 + cyclic_polys.resize (1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
755 + for (unsigned long long i = (1UL<<m)+1; i < (1UL<<(1+m)); i+=2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
756 + if (do_is_cyclic_polynomial (i, n, m)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
757 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
758 + cyclic_polys(0) = (double)i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
759 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
760 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
761 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
762 + case CYCLIC_POLY_MAX: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
763 + cyclic_polys.resize (1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
764 + for (unsigned long long i = (1UL<<(m+1))-1; i > (1UL<<m); i-=2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
765 + if (do_is_cyclic_polynomial (i, n, m)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
766 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
767 + cyclic_polys(0) = (double)i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
768 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
769 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
770 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
771 + case CYCLIC_POLY_ALL: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
772 + for (unsigned long long i = (1UL<<m)+1; i < (1UL<<(1+m)); i+=2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
773 + if (do_is_cyclic_polynomial (i, n, m)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
774 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
775 + cyclic_polys.resize (cyclic_polys.length ()+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
776 + cyclic_polys(cyclic_polys.length ()-1) = (double)i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
777 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
778 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
779 + case CYCLIC_POLY_L: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
780 + for (unsigned long long i = ((unsigned long long)1<<m)+1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
781 + i < ((unsigned long long)1<<(1+m)); i+=2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
782 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
783 + int li = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
784 + for (int j=0; j < m+1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
785 + if (i & ((unsigned long long)1 << j)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
786 + li++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
787 + if (li == l) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
788 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
789 + if (do_is_cyclic_polynomial (i, n, m)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
790 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
791 + cyclic_polys.resize (cyclic_polys.length ()+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
792 + cyclic_polys(cyclic_polys.length ()-1) = (double)i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
793 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
794 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
795 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
796 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
797 + default: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
798 + error ("cyclpoly: impossible"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
799 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
800 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
801 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
802 + if (cyclic_polys.length () == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
803 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
804 + octave_stdout << |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
805 + "cyclpoly: no generator polynomial statifies constraints" << std::endl; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
806 + retval = octave_value (Matrix (0, 0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
807 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
808 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
809 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
810 + if (polyrep) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
811 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
812 + Matrix polys (cyclic_polys.length (), m+1, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
813 + for (int i = 0 ; i < cyclic_polys.length (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
814 + for (int j = 0; j < m+1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
815 + if ((unsigned long long)cyclic_polys(i) & (1<<j)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
816 + polys(i, j) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
817 + retval = octave_value (polys); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
818 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
819 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
820 + retval = octave_value (cyclic_polys); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
821 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
822 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
823 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
824 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
825 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
826 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
827 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
828 +%!error cyclpoly () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
829 +%!error cyclpoly (1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
830 +%!error cyclpoly (1, 2, 3, 4, 5) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
831 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
832 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
833 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
834 +;;; Local Variables: *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
835 +;;; mode: C++ *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
836 +;;; End: *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
837 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
838 diff -uNr a/src/galois.cc b/src/galois.cc |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
839 --- a/src/galois.cc 2018-04-09 13:25:42.880981256 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
840 +++ b/src/galois.cc 2018-04-09 13:53:27.547125644 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
841 @@ -19,7 +19,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
842 // Initiative (www.opensource.org) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
843 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
844 #include <octave/error.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
845 -#include <octave/gripes.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
846 +#include <octave/errwarn.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
847 #include <octave/mx-op-defs.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
848 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
849 #include "galois.h" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
850 @@ -215,7 +215,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
851 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
852 if (nr != a_nr || nc != a_nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
853 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
854 - gripe_nonconformant ("operator +=", nr, nc, a_nr, a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
855 + octave::err_nonconformant ("operator +=", nr, nc, a_nr, a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
856 return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
857 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
858 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
859 @@ -251,7 +251,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
860 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
861 if (nr != a_nr || nc != a_nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
862 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
863 - gripe_nonconformant ("operator -=", nr, nc, a_nr, a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
864 + octave::err_nonconformant ("operator -=", nr, nc, a_nr, a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
865 return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
866 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
867 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
868 @@ -517,7 +517,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
869 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
870 if (a_nr != b_nr || a_nc != b_nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
871 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
872 - gripe_nonconformant ("operator .^", a_nr, a_nc, a_nr, a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
873 + octave::err_nonconformant ("operator .^", a_nr, a_nc, a_nr, a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
874 return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
875 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
876 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
877 @@ -548,7 +548,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
878 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
879 if (a_nr != b_nr || a_nc != b_nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
880 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
881 - gripe_nonconformant ("operator .^", a_nr, a_nc, b_nr, b_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
882 + octave::err_nonconformant ("operator .^", a_nr, a_nc, b_nr, b_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
883 return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
884 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
885 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
886 @@ -757,7 +757,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
887 return product (a, b); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
888 else if (a_nc != b_nr) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
889 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
890 - gripe_nonconformant ("operator *", a_nr, a_nc, b_nr, b_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
891 + octave::err_nonconformant ("operator *", a_nr, a_nc, b_nr, b_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
892 return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
893 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
894 else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
895 @@ -1302,7 +1302,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
896 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
897 // Apply row interchanges to the right hand sides. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
898 //for (int j = 0; j < IP.length (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
899 - for (int j = IP.length ()-1; j >= 0; j--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
900 + for (int j = IP.numel ()-1; j >= 0; j--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
901 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
902 int piv = IP(j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
903 for (int i = 0; i < b_nc; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
904 @@ -1334,7 +1334,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
905 Array<int> IP (fact.ipvt); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
906 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
907 // Apply row interchanges to the right hand sides. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
908 - for (int j = 0; j < IP.length (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
909 + for (int j = 0; j < IP.numel (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
910 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
911 int piv = IP(j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
912 for (int i = 0; i < b_nc; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
913 @@ -1419,7 +1419,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
914 int a_nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
915 int b_nr = b.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
916 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
917 - gripe_nonconformant ("operator /", a_nr, a_nc, b_nr, b_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
918 + octave::err_nonconformant ("operator /", a_nr, a_nc, b_nr, b_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
919 return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
920 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
921 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
922 @@ -1463,7 +1463,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
923 int a_nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
924 int b_nc = b.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
925 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
926 - gripe_nonconformant ("operator \\", a_nr, a_nc, b_nr, b_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
927 + octave::err_nonconformant ("operator \\", a_nr, a_nc, b_nr, b_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
928 return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
929 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
930 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
931 diff -uNr a/src/galois.cc~ b/src/galois.cc~ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
932 --- a/src/galois.cc~ 1969-12-31 19:00:00.000000000 -0500 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
933 +++ b/src/galois.cc~ 2018-04-09 13:37:49.607001400 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
934 @@ -0,0 +1,1494 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
935 +//Copyright (C) 2003 David Bateman |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
936 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
937 +// This program is free software; you can redistribute it and/or |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
938 +// modify it under the terms of the GNU General Public License as |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
939 +// published by the Free Software Foundation; either version 3 of the |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
940 +// License, or (at your option) any later version. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
941 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
942 +// This program is distributed in the hope that it will be useful, but |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
943 +// WITHOUT ANY WARRANTY; without even the implied warranty of |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
944 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
945 +// General Public License for more details. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
946 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
947 +// You should have received a copy of the GNU General Public License |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
948 +// along with this program; if not, see |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
949 +// <http://www.gnu.org/licenses/>. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
950 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
951 +// In addition to the terms of the GPL, you are permitted to link this |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
952 +// program with any Open Source program, as defined by the Open Source |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
953 +// Initiative (www.opensource.org) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
954 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
955 +#include <octave/error.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
956 +#include <octave/errwarn.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
957 +#include <octave/mx-op-defs.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
958 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
959 +#include "galois.h" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
960 +#include "galoisfield.h" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
961 +#include "galois-def.h" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
962 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
963 +#include "base-lu.cc" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
964 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
965 +galois_field_list stored_galois_fields; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
966 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
967 +// galois class |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
968 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
969 +galois::galois (const Array<int>& a, const int& _m, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
970 + const int& _primpoly) : MArray<int> (a.dims ()), field (NULL) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
971 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
972 + int _n = (1<<_m) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
973 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
974 + // Check the validity of the data in the matrix |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
975 + for (int i = 0; i < rows (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
976 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
977 + for (int j = 0; j < columns (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
978 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
979 + if ((a(i, j) < 0) || (a(i, j) > _n)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
980 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
981 + gripe_range_galois (_m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
982 + return; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
983 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
984 + xelem(i, j) = (int)a(i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
985 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
986 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
987 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
988 + field = stored_galois_fields.create_galois_field (_m, _primpoly); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
989 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
990 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
991 +galois::galois (const MArray<int>& a, const int& _m, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
992 + const int& _primpoly) : MArray<int> (a.dims ()), field (NULL) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
993 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
994 + int _n = (1<<_m) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
995 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
996 + // Check the validity of the data in the matrix |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
997 + for (int i = 0; i < rows (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
998 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
999 + for (int j = 0; j < columns (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1000 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1001 + if ((a(i, j) < 0) || (a(i, j) > _n)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1002 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1003 + gripe_range_galois (_m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1004 + return; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1005 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1006 + xelem(i, j) = (int)a(i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1007 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1008 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1009 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1010 + field = stored_galois_fields.create_galois_field (_m, _primpoly); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1011 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1012 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1013 +galois::galois (const Matrix& a, const int& _m, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1014 + const int& _primpoly) : MArray<int> (a.dims ()), field (NULL) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1015 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1016 + int _n = (1<<_m) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1017 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1018 + // Check the validity of the data in the matrix |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1019 + for (int i = 0; i < rows (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1020 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1021 + for (int j = 0; j < columns (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1022 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1023 + if ((a(i, j) < 0) || (a(i, j) > _n)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1024 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1025 + gripe_range_galois (_m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1026 + return; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1027 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1028 + if ((a(i, j) - (double)((int)a(i, j))) != 0.) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1029 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1030 + gripe_integer_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1031 + return; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1032 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1033 + xelem(i, j) = (int)a(i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1034 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1035 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1036 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1037 + field = stored_galois_fields.create_galois_field (_m, _primpoly); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1038 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1039 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1040 +galois::galois (int nr, int nc, const int& val, const int& _m, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1041 + const int& _primpoly) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1042 + : MArray<int> (dim_vector (nr, nc), val), field (NULL) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1043 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1044 + int _n = (1<<_m) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1045 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1046 + // Check the validity of the data in the matrix |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1047 + if ((val < 0) || (val > _n)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1048 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1049 + gripe_range_galois (_m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1050 + return; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1051 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1052 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1053 + field = stored_galois_fields.create_galois_field (_m, _primpoly); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1054 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1055 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1056 +galois::galois (int nr, int nc, double val, const int& _m, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1057 + const int& _primpoly) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1058 + : MArray<int> (dim_vector (nr, nc), (int)val), field (NULL) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1059 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1060 + int _n = (1<<_m) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1061 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1062 + // Check the validity of the data in the matrix |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1063 + if ((val < 0) || (val > _n)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1064 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1065 + gripe_range_galois (_m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1066 + return; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1067 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1068 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1069 + if ((val - (double)((int)val)) != 0.) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1070 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1071 + gripe_integer_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1072 + return; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1073 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1074 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1075 + field = stored_galois_fields.create_galois_field (_m, _primpoly); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1076 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1077 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1078 +galois::galois (const galois& a) : MArray<int> (a) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1079 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1080 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1081 + if (!a.have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1082 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1083 + gripe_copy_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1084 + field = NULL; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1085 + return; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1086 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1087 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1088 + // This call to create_galois_field will just increment the usage counter |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1089 + field = stored_galois_fields.create_galois_field (a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1090 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1091 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1092 +galois::~galois (void) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1093 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1094 + stored_galois_fields.delete_galois_field (field); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1095 + field = NULL; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1096 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1097 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1098 +galois& |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1099 +galois::operator = (const galois& t) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1100 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1101 + if (!t.have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1102 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1103 + gripe_copy_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1104 + if (have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1105 + stored_galois_fields.delete_galois_field (field); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1106 + field = NULL; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1107 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1108 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1109 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1110 + if (have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1111 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1112 + if ((m () != t.m ()) || (primpoly () != t.primpoly ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1113 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1114 + stored_galois_fields.delete_galois_field (field); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1115 + field = stored_galois_fields.create_galois_field (t.m (), t.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1116 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1117 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1118 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1119 + field = stored_galois_fields.create_galois_field (t.m (), t.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1120 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1121 + // Copy the data |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1122 + MArray<int>::operator = (t); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1123 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1124 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1125 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1126 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1127 +galois& |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1128 +galois::operator += (const galois& a) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1129 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1130 + int nr = rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1131 + int nc = cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1132 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1133 + int a_nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1134 + int a_nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1135 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1136 + if (have_field () && a.have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1137 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1138 + if ((m () != a.m ()) || (primpoly () != a.primpoly ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1139 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1140 + gripe_differ_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1141 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1142 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1143 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1144 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1145 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1146 + gripe_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1147 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1148 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1149 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1150 + if (nr != a_nr || nc != a_nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1151 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1152 + octave::err_nonconformant ("operator +=", nr, nc, a_nr, a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1153 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1154 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1155 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1156 + for (int i = 0; i < rows (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1157 + for (int j = 0; j < columns (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1158 + xelem(i, j) ^= a (i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1159 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1160 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1161 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1162 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1163 +galois& |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1164 +galois::operator -= (const galois& a) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1165 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1166 + int nr = rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1167 + int nc = cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1168 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1169 + int a_nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1170 + int a_nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1171 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1172 + if (have_field () && a.have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1173 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1174 + if ((m () != a.m ()) || (primpoly () != a.primpoly ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1175 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1176 + gripe_differ_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1177 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1178 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1179 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1180 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1181 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1182 + gripe_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1183 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1184 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1185 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1186 + if (nr != a_nr || nc != a_nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1187 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1188 + octave::err_nonconformant ("operator -=", nr, nc, a_nr, a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1189 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1190 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1191 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1192 + for (int i = 0; i < rows (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1193 + for (int j = 0; j < columns (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1194 + xelem(i, j) ^= a (i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1195 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1196 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1197 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1198 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1199 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1200 +galois::index (idx_vector& i, int resize_ok, const int& rfv) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1201 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1202 + galois retval (MArray<int>::index(i, resize_ok, rfv), m (), primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1203 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1204 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1205 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1206 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1207 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1208 +galois::index (idx_vector& i, idx_vector& j, int resize_ok, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1209 + const int& rfv) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1210 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1211 + galois retval (MArray<int>::index(i, j, resize_ok, rfv), m (), primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1212 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1213 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1214 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1215 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1216 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1217 +galois::concat (const galois& rb, const Array<int>& ra_idx) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1218 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1219 + if (rb.numel () > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1220 + insert (rb, ra_idx(0), ra_idx(1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1221 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1222 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1223 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1224 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1225 +galois::concat (const Matrix& rb, const Array<int>& ra_idx) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1226 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1227 + if (numel () == 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1228 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1229 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1230 + galois tmp (0, 0, 0, m (), primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1231 + int _n = (1<<m ()) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1232 + int r = rb.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1233 + int c = rb.columns (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1234 + tmp.resize (dim_vector (r, c)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1235 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1236 + // Check the validity of the data in the matrix |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1237 + for (int i = 0; i < r; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1238 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1239 + for (int j = 0; j < c; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1240 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1241 + if ((rb(i, j) < 0) || (rb(i, j) > _n)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1242 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1243 + gripe_range_galois (m ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1244 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1245 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1246 + if ((rb(i, j) - (double)((int)rb(i, j))) != 0.) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1247 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1248 + gripe_integer_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1249 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1250 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1251 + tmp(i, j) = (int)rb(i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1252 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1253 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1254 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1255 + insert (tmp, ra_idx(0), ra_idx(1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1256 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1257 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1258 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1259 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1260 +concat (const Matrix& ra, const galois& rb, const Array<int>& ra_idx) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1261 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1262 + galois retval (0, 0, 0, rb.m (), rb.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1263 + int _n = (1<<rb.m ()) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1264 + int r = ra.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1265 + int c = ra.columns (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1266 + retval.resize (dim_vector (r, c)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1267 + if (ra.numel () < 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1268 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1269 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1270 + // FIXME: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1271 + // Check the validity of the data in the matrix. This is problematic |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1272 + // as "ra" is not initialized on the initial resize and so contains |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1273 + // random data that will be replaced. Humm, disable for now |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1274 + for (int i = 0; i < r; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1275 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1276 + for (int j = 0; j < c; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1277 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1278 +#if 0 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1279 + if ((ra(i, j) < 0) || (ra(i, j) > _n)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1280 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1281 + gripe_range_galois (rb.m ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1282 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1283 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1284 + if ((ra(i, j) - (double)((int)ra(i, j))) != 0.) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1285 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1286 + gripe_integer_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1287 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1288 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1289 + retval(i, j) = (int)ra(i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1290 +#else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1291 + int tmp = (int)ra(i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1292 + if (tmp < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1293 + retval(i, j) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1294 + else if (tmp > _n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1295 + retval(i, j) = _n; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1296 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1297 + retval(i, j) = tmp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1298 +#endif |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1299 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1300 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1301 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1302 + retval.insert (rb, ra_idx(0), ra_idx(1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1303 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1304 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1305 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1306 +galois& |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1307 +galois::insert (const galois& t, int r, int c) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1308 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1309 + if ((m () != t.m ()) || (primpoly () != t.primpoly ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1310 + (*current_liboctave_error_handler) ("inserted galois variable must " |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1311 + "be in the same field"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1312 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1313 + Array<int>::insert (t, r, c); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1314 + return *this; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1315 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1316 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1317 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1318 +galois::diag (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1319 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1320 + return diag (0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1321 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1322 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1323 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1324 +galois::diag (int k) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1325 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1326 + int nnr = rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1327 + int nnc = cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1328 + galois retval (0, 0, 0, m (), primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1329 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1330 + if (k > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1331 + nnc -= k; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1332 + else if (k < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1333 + nnr += k; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1334 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1335 + if (nnr > 0 && nnc > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1336 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1337 + int ndiag = (nnr < nnc) ? nnr : nnc; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1338 + retval.resize (dim_vector (ndiag, 1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1339 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1340 + if (k > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1341 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1342 + for (int i = 0; i < ndiag; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1343 + retval(i, 0) = xelem (i, i+k); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1344 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1345 + else if ( k < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1346 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1347 + for (int i = 0; i < ndiag; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1348 + retval(i, 0) = xelem (i-k, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1349 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1350 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1351 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1352 + for (int i = 0; i < ndiag; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1353 + retval(i, 0) = xelem (i, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1354 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1355 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1356 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1357 + error ("diag: requested diagonal out of range"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1358 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1359 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1360 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1361 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1362 +// unary operations |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1363 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1364 +boolMatrix |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1365 +galois::operator ! (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1366 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1367 + int nr = rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1368 + int nc = cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1369 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1370 + boolMatrix b (nr, nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1371 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1372 + for (int j = 0; j < nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1373 + for (int i = 0; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1374 + b (i, j) = ! xelem (i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1375 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1376 + return b; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1377 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1378 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1379 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1380 +galois::transpose (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1381 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1382 + galois a (Matrix (0, 0), m (), primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1383 + int d1 = rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1384 + int d2 = cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1385 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1386 + a.resize (dim_vector (d2, d1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1387 + for (int j = 0; j < d2; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1388 + for (int i = 0; i < d1; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1389 + a (j, i) = xelem (i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1390 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1391 + return a; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1392 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1393 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1394 +static inline int |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1395 +modn (int x, int m, int n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1396 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1397 + while (x >= n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1398 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1399 + x -= n; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1400 + x = (x >> m) + (x & n); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1401 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1402 + return x; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1403 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1404 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1405 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1406 +elem_pow (const galois& a, const galois& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1407 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1408 + int a_nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1409 + int a_nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1410 + galois result (a_nr, a_nc, 0, a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1411 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1412 + int b_nr = b.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1413 + int b_nc = b.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1414 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1415 + if (a.have_field () && b.have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1416 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1417 + if ((a.m () != b.m ()) || (a.primpoly () != b.primpoly ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1418 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1419 + gripe_differ_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1420 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1421 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1422 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1423 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1424 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1425 + gripe_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1426 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1427 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1428 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1429 + if (a_nr == 1 && a_nc == 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1430 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1431 + result.resize (dim_vector (b_nr, b_nc), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1432 + int tmp = a.index_of (a(0, 0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1433 + for (int j = 0; j < b_nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1434 + for (int i = 0; i < b_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1435 + if (b(i, j) == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1436 + result(i, j) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1437 + else if (a(0, 0) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1438 + result(i, j) = a.alpha_to (modn (tmp * b(i, j), a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1439 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1440 + else if (b_nr == 1 && b_nc == 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1441 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1442 + for (int j = 0; j < a_nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1443 + for (int i = 0; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1444 + if (b(0, 0) == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1445 + result(i, j) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1446 + else if (a(i, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1447 + result(i, j) = a.alpha_to (modn (a.index_of (a(i, j)) * |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1448 + b(0, 0), a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1449 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1450 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1451 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1452 + if (a_nr != b_nr || a_nc != b_nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1453 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1454 + octave::err_nonconformant ("operator .^", a_nr, a_nc, a_nr, a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1455 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1456 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1457 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1458 + for (int j = 0; j < a_nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1459 + for (int i = 0; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1460 + if (b(i, j) == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1461 + result(i, j) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1462 + else if (a(i, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1463 + result(i, j) = a.alpha_to (modn (a.index_of (a(i, j)) * |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1464 + b(i, j), a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1465 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1466 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1467 + return result; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1468 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1469 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1470 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1471 +elem_pow (const galois& a, const Matrix& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1472 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1473 + int a_nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1474 + int a_nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1475 + galois result (a_nr, a_nc, 0, a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1476 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1477 + int b_nr = b.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1478 + int b_nc = b.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1479 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1480 + if (b_nr == 1 && b_nc == 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1481 + return elem_pow (a, b(0, 0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1482 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1483 + if (a_nr != b_nr || a_nc != b_nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1484 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1485 + octave::err_nonconformant ("operator .^", a_nr, a_nc, b_nr, b_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1486 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1487 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1488 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1489 + for (int j = 0; j < a_nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1490 + for (int i = 0; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1491 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1492 + int tmp = (int)b(i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1493 + while (tmp < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1494 + tmp += a.n (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1495 + if (tmp == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1496 + result(i, j) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1497 + else if (a(i, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1498 + result(i, j) = a.alpha_to (modn (a.index_of (a(i, j)) * tmp, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1499 + a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1500 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1501 + return result; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1502 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1503 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1504 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1505 +elem_pow (const galois& a, double b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1506 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1507 + int a_nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1508 + int a_nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1509 + galois result (a_nr, a_nc, 0, a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1510 + int bi = (int) b; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1511 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1512 + if ((double)bi != b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1513 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1514 + gripe_integer_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1515 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1516 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1517 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1518 + while (bi < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1519 + bi += a.n (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1520 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1521 + for (int j = 0; j < a_nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1522 + for (int i = 0; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1523 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1524 + if (bi == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1525 + result(i, j) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1526 + else if (a(i, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1527 + result(i, j) = a.alpha_to (modn (a.index_of (a(i, j)) * |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1528 + bi, a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1529 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1530 + return result; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1531 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1532 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1533 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1534 +elem_pow (const galois &a, int b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1535 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1536 + int a_nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1537 + int a_nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1538 + galois result (a_nr, a_nc, 0, a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1539 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1540 + while (b < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1541 + b += a.n (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1542 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1543 + for (int j = 0; j < a_nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1544 + for (int i = 0; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1545 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1546 + if (b == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1547 + result(i, j) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1548 + else if (a(i, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1549 + result(i, j) = a.alpha_to (modn (a.index_of (a(i, j)) * b, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1550 + a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1551 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1552 + return result; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1553 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1554 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1555 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1556 +pow (const galois& a, double b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1557 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1558 + int bi = (int)b; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1559 + if ((double)bi != b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1560 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1561 + gripe_integer_power_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1562 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1563 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1564 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1565 + return pow (a, bi); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1566 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1567 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1568 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1569 +pow (const galois& a, const galois& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1570 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1571 + int nr = b.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1572 + int nc = b.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1573 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1574 + if (a.have_field () && b.have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1575 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1576 + if ((a.m () != b.m ()) || (a.primpoly () != b.primpoly ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1577 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1578 + gripe_differ_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1579 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1580 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1581 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1582 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1583 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1584 + gripe_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1585 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1586 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1587 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1588 + if (nr != 1 || nc != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1589 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1590 + gripe_square_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1591 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1592 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1593 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1594 + return pow (a, b(0, 0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1595 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1596 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1597 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1598 +pow (const galois& a, int b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1599 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1600 + galois retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1601 + int nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1602 + int nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1603 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1604 + if (!a.have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1605 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1606 + gripe_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1607 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1608 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1609 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1610 + if (nr == 0 || nc == 0 || nr != nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1611 + gripe_square_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1612 + else if (b == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1613 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1614 + retval = galois (nr, nc, 0, a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1615 + for (int i = 0; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1616 + retval(i, i) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1617 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1618 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1619 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1620 + galois atmp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1621 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1622 + if (b < 0 ) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1623 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1624 + atmp = a.inverse (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1625 + b = abs (b); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1626 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1627 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1628 + atmp = a; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1629 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1630 + retval = atmp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1631 + b--; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1632 + while (b > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1633 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1634 + if (b & 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1635 + retval = retval * atmp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1636 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1637 + b >>= 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1638 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1639 + if (b > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1640 + atmp = atmp * atmp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1641 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1642 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1643 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1644 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1645 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1646 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1647 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1648 +operator * (const Matrix& a, const galois& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1649 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1650 + galois tmp (a, b.m (), b.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1651 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1652 + OCTAVE_QUIT; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1653 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1654 + return tmp * b; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1655 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1656 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1657 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1658 +operator * (const galois& a, const Matrix& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1659 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1660 + galois tmp (b, a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1661 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1662 + OCTAVE_QUIT; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1663 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1664 + return a * tmp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1665 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1666 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1667 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1668 +operator * (const galois& a, const galois& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1669 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1670 + if (a.have_field () && b.have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1671 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1672 + if ((a.m () != b.m ()) || (a.primpoly () != b.primpoly ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1673 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1674 + gripe_differ_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1675 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1676 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1677 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1678 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1679 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1680 + gripe_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1681 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1682 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1683 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1684 + int a_nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1685 + int a_nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1686 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1687 + int b_nr = b.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1688 + int b_nc = b.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1689 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1690 + if ((a_nr == 1 && a_nc == 1) || (b_nr == 1 && b_nc == 1)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1691 + return product (a, b); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1692 + else if (a_nc != b_nr) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1693 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1694 + octave::err_nonconformant ("operator *", a_nr, a_nc, b_nr, b_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1695 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1696 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1697 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1698 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1699 + galois retval (a_nr, b_nc, 0, a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1700 + if (a_nr != 0 && a_nc != 0 && b_nc != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1701 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1702 + // This is not optimum for referencing b, but can use vector |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1703 + // to represent index(a(k,j)). Seems to be the fastest. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1704 + galois c (a_nr, 1, 0, a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1705 + for (int j = 0; j < b_nr; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1706 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1707 + for (int k = 0; k < a_nr; k++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1708 + c(k, 0) = a.index_of (a(k, j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1709 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1710 + for (int i = 0; i < b_nc; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1711 + if (b(j, i) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1712 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1713 + int tmp = a.index_of (b(j, i)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1714 + for (int k = 0; k < a_nr; k++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1715 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1716 + if (a(k, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1717 + retval(k, i) = retval(k, i) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1718 + ^ a.alpha_to (modn (tmp + c(k, 0), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1719 + a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1720 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1721 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1722 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1723 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1724 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1725 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1726 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1727 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1728 +// Other operators |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1729 +boolMatrix |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1730 +galois::all (int dim) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1731 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1732 + return do_mx_red_op<bool, int> (*this, dim, mx_inline_all); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1733 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1734 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1735 +boolMatrix |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1736 +galois::any (int dim) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1737 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1738 + return do_mx_red_op<bool, int> (*this, dim, mx_inline_any); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1739 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1740 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1741 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1742 +galois::prod (int dim) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1743 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1744 + if (!have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1745 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1746 + gripe_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1747 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1748 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1749 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1750 + galois retval (0, 0, 0, m (), primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1751 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1752 +#define ROW_EXPR \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1753 + if ((retval(i, 0) == 0) || (elem (i, j) == 0)) \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1754 + retval(i, 0) = 0; \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1755 + else \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1756 + retval(i, 0) = alpha_to (modn (index_of (retval(i, 0)) + \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1757 + index_of (elem (i, j)), m (), n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1758 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1759 +#define COL_EXPR \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1760 + if ((retval(0, j) == 0) || (elem (i, j) == 0)) \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1761 + retval(0, j) = 0; \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1762 + else \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1763 + retval(0, j) = alpha_to (modn (index_of (retval(0, j)) + \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1764 + index_of (elem (i, j)), m (), n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1765 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1766 + GALOIS_REDUCTION_OP (retval, ROW_EXPR, COL_EXPR, 1, 1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1767 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1768 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1769 +#undef ROW_EXPR |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1770 +#undef COL_EXPR |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1771 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1772 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1773 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1774 +galois::sum (int dim) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1775 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1776 + if (!have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1777 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1778 + gripe_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1779 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1780 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1781 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1782 + galois retval (0, 0, 0, m (), primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1783 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1784 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1785 +#define ROW_EXPR \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1786 + retval(i, 0) ^= elem (i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1787 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1788 +#define COL_EXPR \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1789 + retval(0, j) ^= elem (i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1790 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1791 + GALOIS_REDUCTION_OP (retval, ROW_EXPR, COL_EXPR, 0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1792 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1793 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1794 +#undef ROW_EXPR |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1795 +#undef COL_EXPR |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1796 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1797 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1798 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1799 +galois::sumsq (int dim) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1800 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1801 + if (!have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1802 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1803 + gripe_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1804 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1805 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1806 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1807 + galois retval (0, 0, 0, m (), primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1808 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1809 +#define ROW_EXPR \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1810 + if (elem (i, j) != 0) \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1811 + retval(i, 0) ^= alpha_to (modn (2*index_of (elem (i, j)), m (), n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1812 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1813 +#define COL_EXPR \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1814 + if (elem (i, j) != 0) \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1815 + retval(0, j) ^= alpha_to (modn (2*index_of (elem (i, j)), m (), n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1816 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1817 + GALOIS_REDUCTION_OP (retval, ROW_EXPR, COL_EXPR, 0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1818 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1819 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1820 +#undef ROW_EXPR |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1821 +#undef COL_EXPR |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1822 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1823 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1824 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1825 +galois::sqrt (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1826 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1827 + galois retval (*this); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1828 + int nr = rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1829 + int nc = cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1830 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1831 + for (int j = 0; j < nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1832 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1833 + for (int i = 0; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1834 + if (retval.index_of (retval(i, j)) & 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1835 + retval(i, j) = retval.alpha_to ((retval.index_of (retval(i, j)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1836 + + retval.n ()) / 2); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1837 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1838 + retval(i, j) = retval.alpha_to (retval.index_of (retval(i, j)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1839 + / 2); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1840 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1841 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1842 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1843 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1844 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1845 +galois::log (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1846 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1847 + bool warned = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1848 + if (!have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1849 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1850 + gripe_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1851 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1852 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1853 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1854 + galois retval (*this); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1855 + int nr = rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1856 + int nc = cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1857 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1858 + for (int j = 0; j < nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1859 + for (int i = 0; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1860 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1861 + if (retval(i, j) == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1862 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1863 + if (!warned) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1864 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1865 + warning ("log of zero undefined in Galois field"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1866 + warned = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1867 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1868 + // How do I flag a NaN without either |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1869 + // 1) Having to check everytime that the data is valid |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1870 + // 2) Causing overflow in alpha_to or index_of!! |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1871 + retval(i, j) = retval.index_of (retval(i, j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1872 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1873 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1874 + retval(i, j) = retval.index_of (retval(i, j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1875 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1876 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1877 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1878 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1879 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1880 +galois::exp (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1881 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1882 + bool warned = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1883 + if (!have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1884 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1885 + gripe_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1886 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1887 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1888 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1889 + galois retval (*this); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1890 + int nr = rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1891 + int nc = cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1892 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1893 + for (int j = 0; j < nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1894 + for (int i = 0; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1895 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1896 + if (retval(i, j) == n ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1897 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1898 + if (!warned) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1899 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1900 + warning ("warning: exp of 2^m-1 undefined in Galois field"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1901 + warned = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1902 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1903 + // How do I flag a NaN without either |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1904 + // 1) Having to check everytime that the data is valid |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1905 + // 2) Causing overflow in alpha_to or index_of!! |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1906 + retval(i, j) = retval.alpha_to (retval(i, j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1907 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1908 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1909 + retval(i, j) = retval.alpha_to (retval(i, j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1910 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1911 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1912 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1913 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1914 +template class base_lu <galois>; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1915 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1916 +void |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1917 +galoisLU::factor (const galois& a, const pivot_type& typ) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1918 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1919 + int a_nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1920 + int a_nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1921 + int mn = (a_nr > a_nc ? a_nc : a_nr); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1922 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1923 + ptype = typ; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1924 + info = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1925 + ipvt.resize (dim_vector (mn, 1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1926 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1927 + a_fact = a; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1928 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1929 + for (int j = 0; j < mn; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1930 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1931 + int jp = j; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1932 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1933 + // Find the pivot and test for singularity |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1934 + if (ptype == galoisLU::ROW) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1935 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1936 + for (int i = j+1; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1937 + if (a_fact(i, j) > a_fact(jp, j)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1938 + jp = i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1939 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1940 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1941 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1942 + for (int i = j+1; i < a_nc; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1943 + if (a_fact(j, i) > a_fact(j, jp)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1944 + jp = i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1945 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1946 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1947 + ipvt(j) = jp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1948 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1949 + if (a_fact(jp, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1950 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1951 + if (ptype == galoisLU::ROW) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1952 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1953 + // Apply the interchange to columns 1:NC. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1954 + if (jp != j) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1955 + for (int i = 0; i < a_nc; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1956 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1957 + int tmp = a_fact(j, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1958 + a_fact(j, i) = a_fact(jp, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1959 + a_fact(jp, i) = tmp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1960 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1961 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1962 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1963 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1964 + // Apply the interchange to rows 1:NR. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1965 + if (jp != j) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1966 + for (int i = 0; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1967 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1968 + int tmp = a_fact(i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1969 + a_fact(i, j) = a_fact(i, jp); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1970 + a_fact(i, jp) = tmp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1971 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1972 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1973 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1974 + // Compute elements J+1:M of J-th column. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1975 + if ( j < a_nr-1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1976 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1977 + int idxj = a_fact.index_of (a_fact(j, j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1978 + for (int i = j+1; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1979 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1980 + if (a_fact(i, j) == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1981 + a_fact(i, j) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1982 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1983 + a_fact(i, j) = a_fact.alpha_to (modn (a_fact.index_of (a_fact(i, j)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1984 + - idxj + a_fact.n (), a_fact.m (), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1985 + a_fact.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1986 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1987 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1988 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1989 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1990 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1991 + info = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1992 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1993 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1994 + if (j < mn-1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1995 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1996 + // Update trailing submatrix. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1997 + for (int i = j+1; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1998 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1999 + if (a_fact(i, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2000 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2001 + int idxi = a_fact.index_of (a_fact(i, j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2002 + for (int k = j+1; k < a_nc; k++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2003 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2004 + if (a_fact(j, k) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2005 + a_fact(i, k) ^= a_fact.alpha_to (modn (a_fact.index_of (a_fact(j, k)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2006 + + idxi, a_fact.m (), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2007 + a_fact.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2008 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2009 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2010 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2011 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2012 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2013 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2014 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2015 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2016 +galoisLU::L (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2017 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2018 + int a_nr = a_fact.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2019 + int a_nc = a_fact.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2020 + int mn = (a_nr < a_nc ? a_nr : a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2021 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2022 + galois l (a_nr, mn, 0, a_fact.m (), a_fact.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2023 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2024 + for (int i = 0; i < mn; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2025 + l(i, i) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2026 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2027 + for (int j = 0; j < mn; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2028 + for (int i = j+1; i < a_nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2029 + l(i, j) = a_fact (i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2030 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2031 + return l; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2032 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2033 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2034 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2035 +galoisLU::U (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2036 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2037 + int a_nr = a_fact.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2038 + int a_nc = a_fact.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2039 + int mn = (a_nr < a_nc ? a_nr : a_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2040 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2041 + galois u (mn, a_nc, 0, a_fact.m (), a_fact.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2042 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2043 + for (int j = 0; j < a_nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2044 + for (int i = 0; i < (j+1 > mn ? mn : j+1); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2045 + u (i, j) = a_fact (i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2046 + return u; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2047 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2048 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2049 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2050 +galois::inverse (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2051 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2052 + int info; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2053 + return inverse (info); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2054 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2055 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2056 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2057 +galois::inverse (int& info, int force) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2058 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2059 + int nr = rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2060 + int nc = cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2061 + info = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2062 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2063 + if (nr != nc || nr == 0 || nc == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2064 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2065 + (*current_liboctave_error_handler) ("inverse requires square matrix"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2066 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2067 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2068 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2069 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2070 + int info = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2071 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2072 + // Solve with identity matrix to find the inverse. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2073 + galois btmp (nr, nr, 0, m (), primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2074 + for (int i = 0; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2075 + btmp(i, i) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2076 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2077 + galois retval = solve (btmp, info, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2078 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2079 + if (info == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2080 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2081 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2082 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2083 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2084 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2085 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2086 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2087 +galois::determinant (void) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2088 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2089 + int info; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2090 + return determinant (info); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2091 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2092 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2093 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2094 +galois::determinant (int& info) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2095 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2096 + galois retval (1, 1, 0, m (), primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2097 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2098 + int nr = rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2099 + int nc = cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2100 + info = -1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2101 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2102 + if (nr == 0 || nc == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2103 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2104 + info = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2105 + retval(0, 0) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2106 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2107 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2108 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2109 + galoisLU fact (*this); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2110 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2111 + if ( ! fact.singular ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2112 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2113 + galois A (fact.a_fact); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2114 + info = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2115 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2116 + retval(0, 0) = A(0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2117 + for (int i = 1; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2118 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2119 + if ((retval(0, 0) == 0) || (A(i, i) == 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2120 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2121 + retval(0, 0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2122 + error ("What the hell are we doing here!!!"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2123 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2124 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2125 + retval(0, 0) = alpha_to (modn (index_of (retval(0, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2126 + index_of (A(i, i)), m (), n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2127 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2128 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2129 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2130 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2131 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2132 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2133 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2134 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2135 +galois::solve (const galois& b) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2136 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2137 + int info; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2138 + return solve (b, info); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2139 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2140 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2141 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2142 +galois::solve (const galois& b, int& info) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2143 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2144 + return solve (b, info, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2145 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2146 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2147 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2148 +galois::solve (const galois& b, int& info, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2149 + solve_singularity_handler sing_handler) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2150 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2151 + galois retval (b); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2152 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2153 + if (!have_field () || !b.have_field ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2154 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2155 + gripe_invalid_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2156 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2157 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2158 + else if ((m () != b.m ()) || (primpoly () != b.primpoly ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2159 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2160 + gripe_differ_galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2161 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2162 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2163 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2164 + int nr = rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2165 + int nc = cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2166 + int b_nr = b.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2167 + int b_nc = b.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2168 + galois c (nr, 1, 0, m (), primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2169 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2170 + // if (nr == 0 || nc == 0 || nr != nc || nr != b_nr) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2171 + if (nr == 0 || nc == 0 || nr != b_nr) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2172 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2173 + (*current_liboctave_error_handler) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2174 + ("matrix dimension mismatch solution of linear equations"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2175 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2176 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2177 + else if (nc > nr) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2178 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2179 + // Under-determined system, use column interchanges. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2180 + galoisLU fact ((*this), galoisLU::COL); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2181 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2182 + if (fact.singular ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2183 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2184 + info = -1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2185 + if (sing_handler) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2186 + sing_handler (0.0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2187 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2188 + (*current_liboctave_error_handler)("galois matrix singular"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2189 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2190 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2191 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2192 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2193 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2194 + galois A (fact.a_fact); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2195 + Array<int> IP (fact.ipvt); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2196 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2197 + // Resize the number of solution rows if needed |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2198 + if (nc > nr) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2199 + retval.resize (dim_vector (b_nr+nc-nr, b_nc), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2200 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2201 + //Solve L*X = B, overwriting B with X. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2202 + int mn = (nc < nr ? nc : nr); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2203 + for (int k = 0; k < mn; k++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2204 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2205 + for (int i = k+1; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2206 + c(i, 0) = index_of (A(i, k)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2207 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2208 + for (int j = 0; j < b_nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2209 + if (retval(k, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2210 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2211 + int idx = index_of (retval(k, j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2212 + for (int i = k+1; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2213 + if (A(i, k) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2214 + retval(i, j) ^= alpha_to (modn (c(i, 0) + idx, m (), n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2215 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2216 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2217 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2218 + // Solve U*X = B, overwriting B with X. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2219 + for (int k = (nc < nr ? nc-1 : nr-1); k >= 0; k--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2220 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2221 + int mn = k+1 < nr ? k+1 : nr; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2222 + for (int i = 0; i < mn; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2223 + c(i, 0) = index_of (A(i, k)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2224 + mn = k < nr ? k : nr; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2225 + for (int j = 0; j < b_nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2226 + if (retval(k, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2227 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2228 + retval(k, j) = alpha_to (modn (index_of (retval(k, j)) - |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2229 + c(k, 0) + n (), m (), n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2230 + int idx = index_of (retval(k, j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2231 + for (int i = 0; i < mn; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2232 + if (A(i, k) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2233 + retval(i, j) ^= alpha_to (modn (c(i, 0) + idx, m (), n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2234 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2235 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2236 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2237 + // Apply row interchanges to the right hand sides. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2238 + //for (int j = 0; j < IP.length (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2239 + for (int j = IP.length ()-1; j >= 0; j--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2240 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2241 + int piv = IP(j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2242 + for (int i = 0; i < b_nc; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2243 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2244 + int tmp = retval(j, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2245 + retval(j, i) = retval(piv, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2246 + retval(piv, i) = tmp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2247 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2248 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2249 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2250 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2251 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2252 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2253 + galoisLU fact (*this); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2254 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2255 + if (fact.singular ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2256 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2257 + info = -1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2258 + if (sing_handler) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2259 + sing_handler (0.0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2260 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2261 + (*current_liboctave_error_handler)("galois matrix singular"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2262 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2263 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2264 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2265 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2266 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2267 + galois A (fact.a_fact); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2268 + Array<int> IP (fact.ipvt); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2269 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2270 + // Apply row interchanges to the right hand sides. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2271 + for (int j = 0; j < IP.length (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2272 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2273 + int piv = IP(j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2274 + for (int i = 0; i < b_nc; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2275 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2276 + int tmp = retval(j, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2277 + retval(j, i) = retval(piv, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2278 + retval(piv, i) = tmp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2279 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2280 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2281 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2282 + //Solve L*X = B, overwriting B with X. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2283 + int mn = (nc < nr ? nc : nr); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2284 + for (int k = 0; k < mn; k++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2285 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2286 + for (int i = k+1; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2287 + c(i, 0) = index_of (A(i, k)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2288 + for (int j = 0; j < b_nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2289 + if (retval(k, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2290 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2291 + int idx = index_of (retval(k, j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2292 + for (int i = k+1; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2293 + if (A(i, k) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2294 + retval(i, j) ^= alpha_to (modn (c(i, 0) + idx, m (), n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2295 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2296 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2297 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2298 + // Solve U*X = B, overwriting B with X. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2299 + for (int k = (nc < nr ? nc-1 : nr-1); k >= 0; k--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2300 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2301 + int mn = k+1 < nr ? k+1 : nr; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2302 + for (int i = 0; i < mn; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2303 + c(i, 0) = index_of (A(i, k)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2304 + mn = k < nr ? k : nr; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2305 + for (int j = 0; j < b_nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2306 + if (retval(k, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2307 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2308 + retval(k, j) = alpha_to (modn (index_of (retval(k, j)) - |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2309 + c(k, 0) + n (), m (), n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2310 + int idx = index_of (retval(k, j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2311 + for (int i = 0; i < mn; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2312 + if (A(i, k) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2313 + retval(i, j) ^= alpha_to (modn (c(i, 0) + idx, m (), n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2314 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2315 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2316 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2317 + // Resize the number of solution rows if needed |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2318 + if (nc < nr) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2319 + retval.resize (dim_vector (b_nr+nc-nr, b_nc)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2320 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2321 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2322 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2323 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2324 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2325 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2326 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2327 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2328 +xdiv (const galois& a, const Matrix& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2329 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2330 + galois btmp (b, a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2331 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2332 + return xdiv (a, btmp); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2333 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2334 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2335 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2336 +xdiv (const Matrix& a, const galois& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2337 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2338 + galois atmp (a, b.m (), b.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2339 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2340 + return xdiv (atmp, b); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2341 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2342 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2343 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2344 +xdiv (const galois& a, const galois& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2345 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2346 + int info = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2347 + int a_nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2348 + int b_nc = b.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2349 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2350 + // if ((a_nc != b_nc) || (b.rows () != b.cols ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2351 + if (a_nc != b_nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2352 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2353 + int a_nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2354 + int b_nr = b.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2355 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2356 + octave::err_nonconformant ("operator /", a_nr, a_nc, b_nr, b_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2357 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2358 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2359 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2360 + galois atmp = a.transpose (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2361 + galois btmp = b.transpose (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2362 + galois result = btmp.solve (atmp, info, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2363 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2364 + if (info == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2365 + return galois (result.transpose ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2366 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2367 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2368 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2369 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2370 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2371 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2372 +xleftdiv (const galois& a, const Matrix& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2373 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2374 + galois btmp (b, a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2375 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2376 + return xleftdiv (a, btmp); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2377 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2378 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2379 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2380 +xleftdiv (const Matrix& a, const galois& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2381 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2382 + galois atmp (a, b.m (), b.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2383 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2384 + return xleftdiv (atmp, b); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2385 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2386 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2387 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2388 +xleftdiv (const galois& a, const galois& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2389 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2390 + int info = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2391 + int a_nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2392 + int b_nr = b.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2393 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2394 + // if ((a_nr != b_nr) || (a.rows () != a.columns ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2395 + if (a_nr != b_nr) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2396 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2397 + int a_nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2398 + int b_nc = b.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2399 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2400 + octave::err_nonconformant ("operator \\", a_nr, a_nc, b_nr, b_nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2401 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2402 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2403 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2404 + galois result = a.solve (b, info, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2405 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2406 + if (info == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2407 + return result; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2408 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2409 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2410 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2411 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2412 +MM_BIN_OPS1 (galois, galois, galois, 1, 2, GALOIS) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2413 +MM_BIN_OPS1 (galois, galois, Matrix, 1, 2, MATRIX) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2414 +MM_BIN_OPS1 (galois, Matrix, galois, 2, 1, MATRIX) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2415 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2416 +MM_CMP_OPS1 (galois, , galois, , 1, 2, GALOIS) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2417 +MM_CMP_OPS1 (galois, , Matrix, , 1, 2, MATRIX) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2418 +MM_CMP_OPS1 (Matrix, , galois, , 2, 1, MATRIX) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2419 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2420 +MM_BOOL_OPS1 (galois, galois, 0.0, 1, 2, GALOIS) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2421 +MM_BOOL_OPS1 (galois, Matrix, 0.0, 1, 2, MATRIX) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2422 +MM_BOOL_OPS1 (Matrix, galois, 0.0, 2, 1, MATRIX) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2423 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2424 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2425 +;;; Local Variables: *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2426 +;;; mode: C++ *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2427 +;;; End: *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2428 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2429 diff -uNr a/src/galois-def.h b/src/galois-def.h |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2430 --- a/src/galois-def.h 2015-04-04 12:28:43.942510204 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2431 +++ b/src/galois-def.h 2018-04-09 13:37:40.547425139 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2432 @@ -137,7 +137,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2433 r(i, j) = (int)m1(i, j) ^ (int)m2(0, 0); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2434 } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2435 else \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2436 - gripe_nonconformant (#OP, m1_nr, m1_nc, m2_nr, m2_nc); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2437 + octave::err_nonconformant (#OP, m1_nr, m1_nc, m2_nr, m2_nc); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2438 } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2439 else \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2440 { \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2441 @@ -221,7 +221,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2442 } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2443 } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2444 else \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2445 - gripe_nonconformant (#F, m1_nr, m1_nc, m2_nr, m2_nc); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2446 + octave::err_nonconformant (#F, m1_nr, m1_nc, m2_nr, m2_nc); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2447 } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2448 else \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2449 if (m1_nr > 0 && m1_nc > 0) \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2450 @@ -289,7 +289,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2451 r(i, j) = C1 (m1(i, j)) OP C2 (m2(0, 0)); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2452 } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2453 else \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2454 - gripe_nonconformant (#F, m1_nr, m1_nc, m2_nr, m2_nc); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2455 + octave::err_nonconformant (#F, m1_nr, m1_nc, m2_nr, m2_nc); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2456 } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2457 \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2458 return r; \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2459 @@ -350,7 +350,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2460 OP (m2(0, 0) != ZERO); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2461 } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2462 else if ((m1_nr != 0 || m1_nc != 0) && (m2_nr != 0 || m2_nc != 0)) \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2463 - gripe_nonconformant (#F, m1_nr, m1_nc, m2_nr, m2_nc); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2464 + octave::err_nonconformant (#F, m1_nr, m1_nc, m2_nr, m2_nc); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2465 } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2466 \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2467 return r; \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2468 diff -uNr a/src/genqamdemod.cc b/src/genqamdemod.cc |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2469 --- a/src/genqamdemod.cc 2015-04-04 12:28:43.950510022 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2470 +++ b/src/genqamdemod.cc 2018-04-09 13:33:02.852412423 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2471 @@ -36,7 +36,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2472 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2473 int nr1 (args(0).rows ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2474 int nc1 (args(0).columns ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2475 - int arg_is_empty1 = empty_arg ("genqamdemod", nr1, nc1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2476 + int arg_is_empty1 = args(0).isempty (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2477 Matrix y (nr1,nc1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2478 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2479 int nr2 (args(1).rows ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2480 @@ -48,7 +48,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2481 if (arg_is_empty1 > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2482 return octave_value (Matrix ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2483 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2484 - if (args(0).is_real_type () && args(1).is_real_type ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2485 + if (args(0).isreal () && args(1).isreal ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2486 { // Real-valued signal & constellation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2487 Matrix x (args(0).matrix_value ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2488 ColumnVector constellation (args(1).vector_value ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2489 @@ -70,7 +70,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2490 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2491 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2492 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2493 - else if (args(0).is_complex_type () || args(1).is_complex_type ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2494 + else if (args(0).iscomplex () || args(1).iscomplex ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2495 { // Complex-valued input & constellation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2496 ComplexMatrix x (args(0).complex_matrix_value ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2497 ComplexColumnVector constellation (args(1).complex_vector_value ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2498 diff -uNr a/src/gf.cc b/src/gf.cc |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2499 --- a/src/gf.cc 2018-04-09 13:25:42.880981256 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2500 +++ b/src/gf.cc 2018-04-09 14:16:54.029455163 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2501 @@ -30,7 +30,8 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2502 */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2503 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2504 #include <octave/defun-dld.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2505 -#include <octave/gripes.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2506 +#include <octave/errwarn.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2507 +#include <octave/interpreter.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2508 #include <octave/oct-locbuf.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2509 #include <octave/ov.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2510 #include <octave/utils.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2511 @@ -72,7 +73,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2512 // functions, this can't be done at the point. So if more default primitive |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2513 // polynomials are added to galoisfield.cc, need to update the "16" here |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2514 // as well!! |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2515 -DEFUN_DLD (gf, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2516 +DEFMETHOD_DLD (gf, interp, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2517 "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2518 @deftypefn {Loadable Function} {@var{y} =} gf (@var{x})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2519 @deftypefnx {Loadable Function} {@var{y} =} gf (@var{x}, @var{m})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2520 @@ -121,7 +122,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2521 install_s_gm_ops (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2522 install_gm_s_ops (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2523 galois_type_loaded = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2524 - mlock (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2525 + interp.mlock (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2526 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2527 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2528 retval = new octave_galois (data, m, primpoly); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2529 @@ -141,7 +142,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2530 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2531 if ((!galois_type_loaded) || (a.type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2532 octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2533 - gripe_wrong_type_arg ("gdiag", a); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2534 + err_wrong_type_arg ("gdiag", a); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2535 else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2536 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2537 galois m = ((const octave_galois&) a.get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2538 @@ -190,12 +191,12 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2539 else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2540 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2541 galois r = m.diag (k); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2542 - if (r.capacity () > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2543 + if (r.numel () > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2544 retval = new octave_galois (r); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2545 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2546 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2547 else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2548 - gripe_wrong_type_arg ("gdiag", a); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2549 + err_wrong_type_arg ("gdiag", a); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2550 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2551 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2552 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2553 @@ -301,7 +302,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2554 if ((!galois_type_loaded) || (args(0).type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2555 octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2556 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2557 - gripe_wrong_type_arg ("greshape", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2558 + err_wrong_type_arg ("greshape", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2559 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2560 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2561 galois a = ((const octave_galois&) args(0).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2562 @@ -371,7 +372,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2563 } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2564 else \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2565 { \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2566 - gripe_wrong_type_arg (#FCN, arg); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2567 + err_wrong_type_arg (#FCN, arg); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2568 return retval; \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2569 } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2570 } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2571 @@ -468,7 +469,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2572 if (!galois_type_loaded || (args(0).type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2573 octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2574 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2575 - gripe_wrong_type_arg ("gsqrt", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2576 + err_wrong_type_arg ("gsqrt", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2577 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2578 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2579 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2580 @@ -507,7 +508,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2581 if (!galois_type_loaded || (args(0).type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2582 octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2583 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2584 - gripe_wrong_type_arg ("glog", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2585 + err_wrong_type_arg ("glog", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2586 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2587 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2588 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2589 @@ -546,7 +547,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2590 if (!galois_type_loaded || (args(0).type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2591 octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2592 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2593 - gripe_wrong_type_arg ("gexp", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2594 + err_wrong_type_arg ("gexp", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2595 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2596 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2597 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2598 @@ -577,9 +578,9 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2599 galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2600 filter (galois& b, galois& a, galois& x, galois& si) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2601 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2602 - int ab_len = (a.length () > b.length () ? a.length () : b.length ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2603 + int ab_len = (a.numel () > b.numel () ? a.numel () : b.numel ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2604 b.resize (dim_vector (ab_len, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2605 - galois retval (x.length (), 1, 0, b.m (), b.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2606 + galois retval (x.numel (), 1, 0, b.m (), b.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2607 int norm = a(0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2608 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2609 if (norm == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2610 @@ -587,43 +588,43 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2611 error ("gfilter: the first element of a must be non-zero"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2612 return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2613 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2614 - if (si.length () != ab_len - 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2615 + if (si.numel () != ab_len - 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2616 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2617 - error ("gfilter: si must be a vector of length max(length(a), length(b)) - 1"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2618 + error ("gfilter: si must be a vector of length max(numel(a), numel(b)) - 1"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2619 return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2620 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2621 if (norm != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2622 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2623 int idx_norm = b.index_of (norm); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2624 - for (int i = 0; i < b.length (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2625 + for (int i = 0; i < b.numel (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2626 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2627 if (b(i, 0) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2628 b(i, 0) = b.alpha_to (modn (b.index_of (b(i, 0))-idx_norm+b.n (), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2629 b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2630 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2631 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2632 - if (a.length () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2633 + if (a.numel () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2634 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2635 a.resize (dim_vector (ab_len, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2636 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2637 if (norm != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2638 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2639 int idx_norm = a.index_of (norm); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2640 - for (int i = 0; i < a.length (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2641 + for (int i = 0; i < a.numel (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2642 if (a(i, 0) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2643 a(i, 0) = a.alpha_to (modn (a.index_of (a(i, 0))-idx_norm+a.n (), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2644 a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2645 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2646 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2647 - for (int i = 0; i < x.length (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2648 + for (int i = 0; i < x.numel (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2649 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2650 retval(i, 0) = si(0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2651 if ((b(0, 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2652 retval(i, 0) ^= b.alpha_to (modn (b.index_of (b(0, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2653 b.index_of (x(i, 0)), b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2654 - if (si.length () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2655 + if (si.numel () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2656 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2657 - for (int j = 0; j < si.length () - 1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2658 + for (int j = 0; j < si.numel () - 1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2659 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2660 si(j, 0) = si(j+1, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2661 if ((a(j+1, 0) != 0) && (retval(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2662 @@ -633,13 +634,13 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2663 si(j, 0) ^= b.alpha_to (modn (b.index_of (b(j+1, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2664 b.index_of (x(i, 0)), b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2665 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2666 - si(si.length ()-1, 0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2667 - if ((a(si.length (), 0) != 0) && (retval(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2668 - si(si.length ()-1, 0) ^= a.alpha_to (modn (a.index_of (a(si.length (), 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2669 + si(si.numel ()-1, 0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2670 + if ((a(si.numel (), 0) != 0) && (retval(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2671 + si(si.numel ()-1, 0) ^= a.alpha_to (modn (a.index_of (a(si.numel (), 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2672 + a.index_of (retval(i, 0)), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2673 a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2674 - if ((b(si.length (), 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2675 - si(si.length ()-1, 0) ^= b.alpha_to (modn (b.index_of (b(si.length (), 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2676 + if ((b(si.numel (), 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2677 + si(si.numel ()-1, 0) ^= b.alpha_to (modn (b.index_of (b(si.numel (), 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2678 + b.index_of (x(i, 0)), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2679 b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2680 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2681 @@ -655,26 +656,26 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2682 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2683 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2684 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2685 - else if (si.length () > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2686 + else if (si.numel () > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2687 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2688 - for (int i = 0; i < x.length (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2689 + for (int i = 0; i < x.numel (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2690 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2691 retval(i, 0) = si(0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2692 if ((b(0, 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2693 retval(i, 0) ^= b.alpha_to (modn (b.index_of (b(0, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2694 b.index_of (x(i, 0)), b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2695 - if (si.length () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2696 + if (si.numel () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2697 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2698 - for (int j = 0; j < si.length () - 1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2699 + for (int j = 0; j < si.numel () - 1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2700 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2701 si(j, 0) = si(j+1, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2702 if ((b(j+1, 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2703 si(j, 0) ^= b.alpha_to (modn (b.index_of (b(j+1, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2704 b.index_of (x(i, 0)), b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2705 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2706 - si(si.length ()-1, 0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2707 - if ((b(si.length (), 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2708 - si(si.length ()-1, 0) ^= b.alpha_to (modn (b.index_of (b(si.length (), 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2709 + si(si.numel ()-1, 0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2710 + if ((b(si.numel (), 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2711 + si(si.numel ()-1, 0) ^= b.alpha_to (modn (b.index_of (b(si.numel (), 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2712 + b.index_of (x(i, 0)), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2713 b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2714 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2715 @@ -688,7 +689,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2716 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2717 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2718 else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2719 - for (int i = 0; i < x.length (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2720 + for (int i = 0; i < x.numel (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2721 if ((b(0, 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2722 retval(i, 0) = b.alpha_to (modn (b.index_of (b(0, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2723 b.index_of (x(i, 0)), b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2724 @@ -717,7 +718,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2725 @smallexample\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2726 @group\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2727 N M\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2728 - SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k) for 1<=n<=length(x)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2729 + SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k) for 1<=n<=numel(x)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2730 k=0 k=0\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2731 @end group\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2732 @end smallexample\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2733 @@ -729,7 +730,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2734 $a \\in \\Re^{N-1}$, $b \\in \\Re^{M-1}$, and $x \\in \\Re^P$.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2735 @end tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2736 @ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2737 - N=length(a)-1 and M=length(b)-1.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2738 + N=numel(a)-1 and M=numel(b)-1.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2739 @end ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2740 An equivalent form of this equation is:\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2741 @tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2742 @@ -743,7 +744,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2743 @smallexample\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2744 @group\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2745 N M\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2746 - y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k) for 1<=n<=length(x)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2747 + y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k) for 1<=n<=numel(x)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2748 k=1 k=0\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2749 @end group\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2750 @end smallexample\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2751 @@ -838,8 +839,8 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2752 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2753 else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2754 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2755 - int a_len = a.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2756 - int b_len = b.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2757 + int a_len = a.numel (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2758 + int b_len = b.numel (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2759 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2760 int si_len = (a_len > b_len ? a_len : b_len) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2761 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2762 @@ -961,7 +962,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2763 if (!galois_type_loaded || (arg.type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2764 octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2765 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2766 - gripe_wrong_type_arg ("glu", arg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2767 + err_wrong_type_arg ("glu", arg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2768 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2769 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2770 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2771 @@ -970,7 +971,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2772 int nr = arg.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2773 int nc = arg.columns (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2774 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2775 - int arg_is_empty = empty_arg ("glu", nr, nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2776 + int arg_is_empty = arg.isempty (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2777 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2778 if (arg_is_empty < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2779 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2780 @@ -1048,13 +1049,13 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2781 if (!galois_type_loaded || (arg.type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2782 octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2783 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2784 - gripe_wrong_type_arg ("ginverse", arg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2785 + err_wrong_type_arg ("ginverse", arg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2786 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2787 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2788 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2789 galois m = ((const octave_galois&) arg.get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2790 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2791 - int arg_is_empty = empty_arg ("ginverse", nr, nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2792 + int arg_is_empty = arg.isempty (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2793 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2794 if (arg_is_empty < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2795 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2796 @@ -1065,7 +1066,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2797 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2798 if (nr != nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2799 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2800 - gripe_square_matrix_required ("ginverse"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2801 + err_square_matrix_required ("ginverse", "X"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2802 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2803 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2804 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2805 @@ -1142,7 +1143,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2806 if (!galois_type_loaded || (arg.type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2807 octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2808 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2809 - gripe_wrong_type_arg ("gdet", arg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2810 + err_wrong_type_arg ("gdet", arg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2811 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2812 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2813 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2814 @@ -1151,7 +1152,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2815 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2816 galois m = ((const octave_galois&) arg.get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2817 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2818 - int arg_is_empty = empty_arg ("gdet", nr, nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2819 + int arg_is_empty = arg.isempty (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2820 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2821 if (arg_is_empty < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2822 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2823 @@ -1163,7 +1164,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2824 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2825 if (nr != nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2826 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2827 - gripe_square_matrix_required ("det"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2828 + err_square_matrix_required ("det", "A"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2829 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2830 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2831 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2832 @@ -1202,7 +1203,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2833 if (!galois_type_loaded || (arg.type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2834 octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2835 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2836 - gripe_wrong_type_arg ("grank", arg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2837 + err_wrong_type_arg ("grank", arg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2838 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2839 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2840 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2841 @@ -1211,7 +1212,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2842 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2843 galois m = ((const octave_galois&) arg.get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2844 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2845 - int arg_is_empty = empty_arg ("grank", nr, nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2846 + int arg_is_empty = arg.isempty (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2847 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2848 if (arg_is_empty > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2849 retval = 0.0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2850 @@ -1332,7 +1333,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2851 if (!galois_type_loaded || (args(0).type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2852 octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2853 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2854 - gripe_wrong_type_arg ("rsenc", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2855 + err_wrong_type_arg ("rsenc", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2856 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2857 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2858 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2859 @@ -1873,7 +1874,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2860 if (!galois_type_loaded || (args(0).type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2861 octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2862 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2863 - gripe_wrong_type_arg ("rsdec", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2864 + err_wrong_type_arg ("rsdec", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2865 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2866 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2867 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2868 diff -uNr a/src/gf.cc~ b/src/gf.cc~ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2869 --- a/src/gf.cc~ 1969-12-31 19:00:00.000000000 -0500 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2870 +++ b/src/gf.cc~ 2018-04-09 14:12:50.168734516 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2871 @@ -0,0 +1,2809 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2872 +// Copyright (C) 1994-1997 Robert Morelos-Zaragoza <owner@eccpage.com> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2873 +// Copyright (C) 2002 Phil Karn <karn@ka9q.net> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2874 +// Copyright (C) 2003 David Bateman |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2875 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2876 +// This program is free software; you can redistribute it and/or |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2877 +// modify it under the terms of the GNU General Public License as |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2878 +// published by the Free Software Foundation; either version 3 of the |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2879 +// License, or (at your option) any later version. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2880 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2881 +// This program is distributed in the hope that it will be useful, but |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2882 +// WITHOUT ANY WARRANTY; without even the implied warranty of |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2883 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2884 +// General Public License for more details. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2885 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2886 +// You should have received a copy of the GNU General Public License |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2887 +// along with this program; if not, see |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2888 +// <http://www.gnu.org/licenses/>. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2889 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2890 +// In addition to the terms of the GPL, you are permitted to link this |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2891 +// program with any Open Source program, as defined by the Open Source |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2892 +// Initiative (www.opensource.org) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2893 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2894 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2895 +Part of the function rsenc and the function decode_rs are from Phil Karn. See |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2896 +the website http://www.ka9q.net/code/fec for more details. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2897 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2898 +Parts of the function bchenco and bchdeco are from Robert Morelos-Zaragoza. See |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2899 +the website http://www.eccpage.com for more details. Permission has been granted |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2900 +for a GPL release of his code |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2901 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2902 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2903 +#include <octave/defun-dld.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2904 +#include <octave/errwarn.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2905 +#include <octave/interpreter.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2906 +#include <octave/oct-locbuf.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2907 +#include <octave/ov.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2908 +#include <octave/utils.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2909 +#include <octave/variables.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2910 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2911 +#include "galois.h" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2912 +#include "ov-galois.h" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2913 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2914 +static bool galois_type_loaded = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2915 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2916 +// PKG_ADD: autoload ("isgalois", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2917 +// PKG_DEL: autoload ("isgalois", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2918 +DEFUN_DLD (isgalois, args, , |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2919 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2920 +@deftypefn {Loadable Function} {} isgalois (@var{expr})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2921 +Return 1 if the value of the expression @var{expr} is a Galois Field.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2922 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2923 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2924 + if (args.length () != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2925 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2926 + else if (!galois_type_loaded) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2927 + // Can be of Galois type if the type isn't load :-/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2928 + return octave_value (0.); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2929 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2930 + return octave_value (args(0).type_id () == |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2931 + octave_galois::static_type_id ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2932 + return octave_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2933 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2934 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2935 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2936 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2937 +%!error isgalois () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2938 +%!error isgalois (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2939 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2940 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2941 +// FIXME: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2942 +// I want to replace the "16" below with __OCTAVE_GALOIS_MAX_M_AS_STRING, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2943 +// but as I don't run the preprocessor when getting the help from the |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2944 +// functions, this can't be done at the point. So if more default primitive |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2945 +// polynomials are added to galoisfield.cc, need to update the "16" here |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2946 +// as well!! |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2947 +DEFMETHOD_DLD (interp, gf, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2948 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2949 +@deftypefn {Loadable Function} {@var{y} =} gf (@var{x})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2950 +@deftypefnx {Loadable Function} {@var{y} =} gf (@var{x}, @var{m})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2951 +@deftypefnx {Loadable Function} {@var{y} =} gf (@var{x}, @var{m}, @var{primpoly})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2952 +Creates a Galois field array GF(2^@var{m}) from the matrix @var{x}. The\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2953 +Galois field has 2^@var{m} elements, where @var{m} must be between 1 and 16.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2954 +The elements of @var{x} must be between 0 and 2^@var{m} - 1. If @var{m} is\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2955 +undefined it defaults to the value 1.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2956 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2957 +The primitive polynomial to use in the creation of Galois field can be\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2958 +specified with the @var{primpoly} variable. If this is undefined a default\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2959 +primitive polynomial is used. It should be noted that the primitive\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2960 +polynomial must be of the degree @var{m} and it must be irreducible.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2961 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2962 +The output of this function is recognized as a Galois field by Octave and\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2963 +other matrices will be converted to the same Galois field when used in an\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2964 +arithmetic operation with a Galois field.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2965 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2966 +@seealso{isprimitive, primpoly}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2967 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2968 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2969 + Matrix data; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2970 + octave_value retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2971 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2972 + int m = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2973 + int primpoly = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2974 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2975 + if (nargin < 1 || nargin > 3) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2976 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2977 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2978 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2979 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2980 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2981 + data = args(0).matrix_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2982 + if (nargin > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2983 + m = args(1).int_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2984 + if (nargin > 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2985 + primpoly = args(2).int_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2986 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2987 + if (!galois_type_loaded) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2988 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2989 + octave_galois::register_type (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2990 + install_gm_gm_ops (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2991 + install_m_gm_ops (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2992 + install_gm_m_ops (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2993 + install_s_gm_ops (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2994 + install_gm_s_ops (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2995 + galois_type_loaded = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2996 + interp.mlock (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2997 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2998 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2999 + retval = new octave_galois (data, m, primpoly); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3000 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3001 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3002 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3003 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3004 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3005 +%!error gf () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3006 +%!error gf (1, 2, 3, 4) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3007 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3008 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3009 +static octave_value |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3010 +make_gdiag (const octave_value& a, const octave_value& b) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3011 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3012 + octave_value retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3013 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3014 + if ((!galois_type_loaded) || (a.type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3015 + octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3016 + err_wrong_type_arg ("gdiag", a); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3017 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3018 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3019 + galois m = ((const octave_galois&) a.get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3020 + int k = b.nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3021 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3022 + if (! error_state) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3023 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3024 + int nr = m.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3025 + int nc = m.columns (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3026 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3027 + if (nr == 0 || nc == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3028 + retval = new octave_galois (m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3029 + else if (nr == 1 || nc == 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3030 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3031 + int roff = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3032 + int coff = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3033 + if (k > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3034 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3035 + roff = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3036 + coff = k; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3037 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3038 + else if (k < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3039 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3040 + k = -k; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3041 + roff = k; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3042 + coff = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3043 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3044 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3045 + if (nr == 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3046 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3047 + int n = nc + k; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3048 + galois r (n, n, 0, m.m (), m.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3049 + for (int i = 0; i < nc; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3050 + r (i+roff, i+coff) = m (0, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3051 + retval = new octave_galois (r); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3052 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3053 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3054 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3055 + int n = nr + k; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3056 + galois r (n, n, 0, m.m (), m.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3057 + for (int i = 0; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3058 + r (i+roff, i+coff) = m (i, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3059 + retval = new octave_galois (r); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3060 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3061 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3062 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3063 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3064 + galois r = m.diag (k); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3065 + if (r.numel () > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3066 + retval = new octave_galois (r); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3067 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3068 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3069 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3070 + err_wrong_type_arg ("gdiag", a); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3071 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3072 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3073 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3074 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3075 +// PKG_ADD: autoload ("gdiag", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3076 +// PKG_DEL: autoload ("gdiag", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3077 +DEFUN_DLD (gdiag, args, , |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3078 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3079 +@deftypefn {Loadable Function} {} gdiag (@var{v}, @var{k})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3080 +Return a diagonal matrix with Galois vector @var{v} on diagonal @var{k}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3081 +The second argument is optional. If it is positive, the vector is placed on\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3082 +the @var{k}-th super-diagonal. If it is negative, it is placed on the\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3083 +@var{-k}-th sub-diagonal. The default value of @var{k} is 0, and the\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3084 +vector is placed on the main diagonal. For example,\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3085 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3086 +@example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3087 +gdiag (gf ([1, 2, 3], 2), 1)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3088 +ans =\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3089 +GF(2^2) array. Primitive Polynomial = D^2+D+1 (decimal 7)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3090 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3091 +Array elements =\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3092 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3093 + 0 1 0 0\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3094 + 0 0 2 0\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3095 + 0 0 0 3\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3096 + 0 0 0 0\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3097 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3098 +@end example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3099 +@seealso{diag}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3100 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3101 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3102 + octave_value retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3103 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3104 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3105 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3106 + if (nargin == 1 && args(0).is_defined ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3107 + retval = make_gdiag (args(0), octave_value (0.)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3108 + else if (nargin == 2 && args(0).is_defined () && args(1).is_defined ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3109 + retval = make_gdiag (args(0), args(1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3110 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3111 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3112 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3113 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3114 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3115 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3116 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3117 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3118 +%!error gdiag () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3119 +%!error gdiag (1, 2, 3) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3120 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3121 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3122 +// PKG_ADD: autoload ("greshape", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3123 +// PKG_DEL: autoload ("greshape", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3124 +DEFUN_DLD (greshape, args, , |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3125 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3126 +@deftypefn {Loadable Function} {} greshape (@var{a}, @var{m}, @var{n})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3127 +Return a matrix with @var{m} rows and @var{n} columns whose elements are\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3128 +taken from the Galois array @var{a}. To decide how to order the elements,\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3129 +Octave pretends that the elements of a matrix are stored in column-major\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3130 +order (like Fortran arrays are stored).\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3131 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3132 +For example,\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3133 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3134 +@example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3135 +greshape (gf ([1, 2, 3, 4], 3), 2, 2)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3136 +ans =\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3137 +GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3138 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3139 +Array elements =\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3140 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3141 + 1 3\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3142 + 2 4\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3143 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3144 +@end example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3145 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3146 +The @code{greshape} function is equivalent to\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3147 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3148 +@example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3149 +@group\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3150 +retval = gf (zeros (m, n), a.m, a.prim_poly);\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3151 +retval(:) = a;\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3152 +@end group\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3153 +@end example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3154 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3155 +@noindent\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3156 +but it is somewhat less cryptic to use @code{reshape} instead of the\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3157 +colon operator. Note that the total number of elements in the original\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3158 +matrix must match the total number of elements in the new matrix.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3159 +@seealso{reshape, :}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3160 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3161 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3162 + octave_value retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3163 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3164 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3165 + if (nargin != 2 && nargin != 3) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3166 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3167 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3168 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3169 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3170 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3171 + int mr = 0, mc = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3172 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3173 + if ((!galois_type_loaded) || (args(0).type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3174 + octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3175 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3176 + err_wrong_type_arg ("greshape", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3177 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3178 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3179 + galois a = ((const octave_galois&) args(0).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3180 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3181 + if (nargin == 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3182 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3183 + RowVector tmp = args(1).row_vector_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3184 + mr = (int)tmp(0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3185 + mc = (int)tmp(1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3186 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3187 + else if (nargin == 3) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3188 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3189 + mr = args(1).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3190 + mc = args(2).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3191 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3192 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3193 + int nr = a.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3194 + int nc = a.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3195 + if ((nr * nc) != (mr * mc)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3196 + error ("greshape: sizes must match"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3197 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3198 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3199 + RowVector tmp1 (mr*mc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3200 + for (int i = 0; i < nr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3201 + for (int j = 0; j < nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3202 + tmp1(i+j*nr) = (double)a(i, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3203 + galois tmp2 (mr, mc, 0, a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3204 + for (int i = 0; i < mr; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3205 + for (int j = 0; j < mc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3206 + tmp2(i, j) = (int)tmp1(i+j*mr); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3207 + retval = new octave_galois (tmp2); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3208 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3209 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3210 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3211 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3212 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3213 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3214 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3215 +%!error greshape () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3216 +%!error greshape (1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3217 +%!error greshape (1, 2, 3, 4) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3218 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3219 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3220 +#define DATA_REDUCTION(FCN) \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3221 + \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3222 + octave_value_list retval; \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3223 + \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3224 + int nargin = args.length (); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3225 + \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3226 + if (nargin == 1 || nargin == 2) \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3227 + { \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3228 + octave_value arg = args(0); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3229 + \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3230 + int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3231 + \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3232 + if (! error_state) \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3233 + { \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3234 + if (dim <= 1 && dim >= -1) \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3235 + { \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3236 + if (galois_type_loaded && (arg.type_id () == \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3237 + octave_galois::static_type_id ())) \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3238 + { \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3239 + galois tmp = ((const octave_galois&)arg.get_rep ()).galois_value (); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3240 + \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3241 + if (! error_state) \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3242 + retval(0) = new octave_galois (tmp.FCN (dim)); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3243 + } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3244 + else \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3245 + { \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3246 + err_wrong_type_arg (#FCN, arg); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3247 + return retval; \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3248 + } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3249 + } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3250 + else \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3251 + error (#FCN ": invalid dimension argument = %d", dim + 1); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3252 + } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3253 + } \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3254 + else \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3255 + print_usage (); \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3256 + \ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3257 + return retval |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3258 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3259 +// PKG_ADD: autoload ("gprod", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3260 +// PKG_DEL: autoload ("gprod", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3261 +DEFUN_DLD (gprod, args, , |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3262 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3263 +@deftypefn {Loadable Function} {} gprod (@var{x}, @var{dim})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3264 +Product of elements along dimension @var{dim} of Galois array. If\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3265 +@var{dim} is omitted, it defaults to 1 (column-wise products).\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3266 +@seealso{prod}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3267 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3268 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3269 + DATA_REDUCTION (prod); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3270 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3271 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3272 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3273 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3274 +%!error gprod () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3275 +%!error gprod (1, 2, 3) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3276 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3277 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3278 +// PKG_ADD: autoload ("gsum", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3279 +// PKG_DEL: autoload ("gsum", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3280 +DEFUN_DLD (gsum, args, , |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3281 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3282 +@deftypefn {Loadable Function} {} gsum (@var{x}, @var{dim})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3283 +Sum of elements along dimension @var{dim} of Galois array. If @var{dim}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3284 +is omitted, it defaults to 1 (column-wise sum).\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3285 +@seealso{sum}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3286 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3287 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3288 + DATA_REDUCTION (sum); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3289 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3290 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3291 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3292 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3293 +%!error gsum () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3294 +%!error gsum (1, 2, 3) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3295 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3296 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3297 +// PKG_ADD: autoload ("gsumsq", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3298 +// PKG_DEL: autoload ("gsumsq", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3299 +DEFUN_DLD (gsumsq, args, , |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3300 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3301 +@deftypefn {Loadable Function} {} gsumsq (@var{x}, @var{dim})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3302 +Sum of squares of elements along dimension @var{dim} of Galois array.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3303 +If @var{dim} is omitted, it defaults to 1 (column-wise sum of squares).\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3304 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3305 +This function is equivalent to computing\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3306 +@example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3307 +gsum (x .* conj (x), dim)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3308 +@end example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3309 +but it uses less memory.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3310 +@seealso{sumsq}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3311 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3312 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3313 + DATA_REDUCTION (sumsq); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3314 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3315 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3316 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3317 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3318 +%!error gsumsq () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3319 +%!error gsumsq (1, 2, 3) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3320 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3321 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3322 +// PKG_ADD: autoload ("gsqrt", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3323 +// PKG_DEL: autoload ("gsqrt", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3324 +DEFUN_DLD (gsqrt, args, , |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3325 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3326 +@deftypefn {Loadable Function} {} gsqrt (@var{x})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3327 +Compute the square root of @var{x}, element by element, in a Galois Field.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3328 +@seealso{exp}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3329 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3330 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3331 + octave_value retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3332 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3333 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3334 + if (nargin != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3335 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3336 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3337 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3338 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3339 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3340 + if (!galois_type_loaded || (args(0).type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3341 + octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3342 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3343 + err_wrong_type_arg ("gsqrt", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3344 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3345 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3346 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3347 + galois a = ((const octave_galois&) args(0).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3348 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3349 + retval = new octave_galois (a.sqrt ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3350 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3351 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3352 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3353 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3354 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3355 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3356 +%!error gsqrt () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3357 +%!error gsqrt (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3358 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3359 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3360 +// PKG_ADD: autoload ("glog", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3361 +// PKG_DEL: autoload ("glog", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3362 +DEFUN_DLD (glog, args, , |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3363 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3364 +@deftypefn {Loadable Function} {} glog (@var{x})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3365 +Compute the natural logarithm for each element of @var{x} for a Galois\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3366 +array.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3367 +@seealso{log}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3368 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3369 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3370 + octave_value retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3371 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3372 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3373 + if (nargin != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3374 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3375 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3376 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3377 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3378 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3379 + if (!galois_type_loaded || (args(0).type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3380 + octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3381 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3382 + err_wrong_type_arg ("glog", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3383 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3384 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3385 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3386 + galois a = ((const octave_galois&) args(0).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3387 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3388 + retval = new octave_galois (a.log ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3389 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3390 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3391 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3392 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3393 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3394 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3395 +%!error glog () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3396 +%!error glog (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3397 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3398 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3399 +// PKG_ADD: autoload ("gexp", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3400 +// PKG_DEL: autoload ("gexp", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3401 +DEFUN_DLD (gexp, args, , |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3402 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3403 +@deftypefn {Loadable Function} {} gexp (@var{x})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3404 +Compute the anti-logarithm for each element of @var{x} for a Galois\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3405 +array.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3406 +@seealso{exp}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3407 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3408 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3409 + octave_value retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3410 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3411 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3412 + if (nargin != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3413 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3414 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3415 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3416 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3417 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3418 + if (!galois_type_loaded || (args(0).type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3419 + octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3420 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3421 + err_wrong_type_arg ("gexp", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3422 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3423 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3424 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3425 + galois a = ((const octave_galois&) args(0).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3426 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3427 + retval = new octave_galois (a.exp ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3428 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3429 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3430 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3431 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3432 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3433 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3434 +%!error gexp () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3435 +%!error gexp (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3436 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3437 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3438 +static inline int |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3439 +modn (int x, int m, int n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3440 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3441 + while (x >= n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3442 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3443 + x -= n; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3444 + x = (x >> m) + (x & n); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3445 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3446 + return x; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3447 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3448 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3449 +galois |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3450 +filter (galois& b, galois& a, galois& x, galois& si) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3451 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3452 + int ab_len = (a.numel () > b.numel () ? a.numel () : b.numel ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3453 + b.resize (dim_vector (ab_len, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3454 + galois retval (x.numel (), 1, 0, b.m (), b.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3455 + int norm = a(0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3456 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3457 + if (norm == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3458 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3459 + error ("gfilter: the first element of a must be non-zero"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3460 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3461 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3462 + if (si.numel () != ab_len - 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3463 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3464 + error ("gfilter: si must be a vector of length max(numel(a), numel(b)) - 1"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3465 + return galois (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3466 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3467 + if (norm != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3468 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3469 + int idx_norm = b.index_of (norm); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3470 + for (int i = 0; i < b.numel (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3471 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3472 + if (b(i, 0) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3473 + b(i, 0) = b.alpha_to (modn (b.index_of (b(i, 0))-idx_norm+b.n (), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3474 + b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3475 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3476 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3477 + if (a.numel () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3478 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3479 + a.resize (dim_vector (ab_len, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3480 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3481 + if (norm != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3482 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3483 + int idx_norm = a.index_of (norm); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3484 + for (int i = 0; i < a.numel (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3485 + if (a(i, 0) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3486 + a(i, 0) = a.alpha_to (modn (a.index_of (a(i, 0))-idx_norm+a.n (), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3487 + a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3488 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3489 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3490 + for (int i = 0; i < x.numel (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3491 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3492 + retval(i, 0) = si(0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3493 + if ((b(0, 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3494 + retval(i, 0) ^= b.alpha_to (modn (b.index_of (b(0, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3495 + b.index_of (x(i, 0)), b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3496 + if (si.numel () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3497 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3498 + for (int j = 0; j < si.numel () - 1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3499 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3500 + si(j, 0) = si(j+1, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3501 + if ((a(j+1, 0) != 0) && (retval(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3502 + si(j, 0) ^= a.alpha_to (modn (a.index_of (a(j+1, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3503 + a.index_of (retval(i, 0)), a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3504 + if ((b(j+1, 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3505 + si(j, 0) ^= b.alpha_to (modn (b.index_of (b(j+1, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3506 + b.index_of (x(i, 0)), b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3507 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3508 + si(si.numel ()-1, 0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3509 + if ((a(si.numel (), 0) != 0) && (retval(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3510 + si(si.numel ()-1, 0) ^= a.alpha_to (modn (a.index_of (a(si.numel (), 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3511 + + a.index_of (retval(i, 0)), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3512 + a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3513 + if ((b(si.numel (), 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3514 + si(si.numel ()-1, 0) ^= b.alpha_to (modn (b.index_of (b(si.numel (), 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3515 + + b.index_of (x(i, 0)), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3516 + b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3517 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3518 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3519 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3520 + si(0, 0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3521 + if ((a(1, 0) != 0) && (retval(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3522 + si(0, 0) ^= a.alpha_to (modn (a.index_of (a(1, 0))+ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3523 + a.index_of (retval(i, 0)), a.m (), a.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3524 + if ((b(1, 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3525 + si(0, 0) ^= b.alpha_to (modn (b.index_of (b(1, 0))+ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3526 + b.index_of (x(i, 0)), b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3527 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3528 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3529 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3530 + else if (si.numel () > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3531 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3532 + for (int i = 0; i < x.numel (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3533 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3534 + retval(i, 0) = si(0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3535 + if ((b(0, 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3536 + retval(i, 0) ^= b.alpha_to (modn (b.index_of (b(0, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3537 + b.index_of (x(i, 0)), b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3538 + if (si.numel () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3539 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3540 + for (int j = 0; j < si.numel () - 1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3541 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3542 + si(j, 0) = si(j+1, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3543 + if ((b(j+1, 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3544 + si(j, 0) ^= b.alpha_to (modn (b.index_of (b(j+1, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3545 + b.index_of (x(i, 0)), b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3546 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3547 + si(si.numel ()-1, 0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3548 + if ((b(si.numel (), 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3549 + si(si.numel ()-1, 0) ^= b.alpha_to (modn (b.index_of (b(si.numel (), 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3550 + + b.index_of (x(i, 0)), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3551 + b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3552 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3553 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3554 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3555 + si(0, 0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3556 + if ((b(1, 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3557 + si(0, 0) ^= b.alpha_to (modn (b.index_of (b(1, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3558 + b.index_of (x(i, 0)), b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3559 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3560 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3561 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3562 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3563 + for (int i = 0; i < x.numel (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3564 + if ((b(0, 0) != 0) && (x(i, 0) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3565 + retval(i, 0) = b.alpha_to (modn (b.index_of (b(0, 0)) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3566 + b.index_of (x(i, 0)), b.m (), b.n ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3567 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3568 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3569 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3570 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3571 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3572 +// PKG_ADD: autoload ("gfilter", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3573 +// PKG_DEL: autoload ("gfilter", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3574 +DEFUN_DLD (gfilter, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3575 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3576 +@deftypefn {Loadable Function} {y =} gfilter (@var{b}, @var{a}, @var{x})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3577 +@deftypefnx {Loadable Function} {[@var{y}, @var{sf}] =} gfilter (@var{b}, @var{a}, @var{x}, @var{si})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3578 +Digital filtering of vectors in a Galois Field. Returns the solution to\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3579 +the following linear, time-invariant difference equation over a Galois\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3580 +Field:\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3581 +@tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3582 +$$\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3583 +\\sum_{k=0}^N a_{k+1} y_{n-k} = \\sum_{k=0}^M b_{k+1} x_{n-k}, \\qquad\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3584 + 1 \\le n \\le P\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3585 +$$\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3586 +@end tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3587 +@ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3588 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3589 +@smallexample\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3590 +@group\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3591 + N M\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3592 + SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k) for 1<=n<=numel(x)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3593 + k=0 k=0\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3594 +@end group\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3595 +@end smallexample\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3596 +@end ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3597 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3598 +@noindent\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3599 +where\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3600 +@tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3601 + $a \\in \\Re^{N-1}$, $b \\in \\Re^{M-1}$, and $x \\in \\Re^P$.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3602 +@end tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3603 +@ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3604 + N=numel(a)-1 and M=numel(b)-1.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3605 +@end ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3606 +An equivalent form of this equation is:\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3607 +@tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3608 +$$\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3609 +y_n = -\\sum_{k=1}^N c_{k+1} y_{n-k} + \\sum_{k=0}^M d_{k+1} x_{n-k}, \\qquad\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3610 + 1 \\le n \\le P\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3611 +$$\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3612 +@end tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3613 +@ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3614 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3615 +@smallexample\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3616 +@group\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3617 + N M\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3618 + y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k) for 1<=n<=numel(x)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3619 + k=1 k=0\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3620 +@end group\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3621 +@end smallexample\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3622 +@end ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3623 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3624 +@noindent\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3625 +where\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3626 +@tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3627 +$c = a/a_1$ and $d = b/a_1$.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3628 +@end tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3629 +@ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3630 + c = a/a(1) and d = b/a(1).\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3631 +@end ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3632 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3633 +If the fourth argument @var{si} is provided, it is taken as the initial\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3634 +state of the system and the final state is returned as @var{sf}. The\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3635 +state vector is a column vector whose length is equal to the length of\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3636 +the longest coefficient vector minus one. If @var{si} is not supplied,\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3637 +the initial state vector is set to all zeros.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3638 +@seealso{filter}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3639 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3640 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3641 + octave_value_list retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3642 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3643 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3644 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3645 + if (nargin < 3 || nargin > 4) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3646 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3647 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3648 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3649 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3650 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3651 + if (!galois_type_loaded) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3652 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3653 + error ("gfilter: wrong argument types"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3654 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3655 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3656 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3657 + bool x_is_row_vector = (args(2).rows () == 1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3658 + bool si_is_row_vector = (nargin == 4 && args(3).rows () == 1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3659 + galois b, a, x, si; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3660 + bool ib=false, ia=false, ix = false, isi=false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3661 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3662 + if (args(0).type_id () == octave_galois::static_type_id ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3663 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3664 + b = ((const octave_galois&) args(0).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3665 + ib = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3666 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3667 + if (args(1).type_id () == octave_galois::static_type_id ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3668 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3669 + a = ((const octave_galois&) args(1).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3670 + ia = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3671 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3672 + if (args(2).type_id () == octave_galois::static_type_id ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3673 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3674 + x = ((const octave_galois&) args(2).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3675 + ix = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3676 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3677 + if (nargin == 4) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3678 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3679 + if (args(3).type_id () == octave_galois::static_type_id ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3680 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3681 + si = ((const octave_galois&) args(3).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3682 + isi = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3683 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3684 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3685 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3686 + if (!ib && !ia && !ix && !isi) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3687 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3688 + error ("gfilter: wrong argument types"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3689 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3690 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3691 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3692 + if (!ib) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3693 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3694 + if (ia) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3695 + b = galois (args(0).matrix_value (), a.m (), a.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3696 + else if (ix) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3697 + b = galois (args(0).matrix_value (), x.m (), x.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3698 + else if (isi) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3699 + b = galois (args(0).matrix_value (), si.m (), si.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3700 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3701 + if (!ia) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3702 + a = galois (args(1).matrix_value (), b.m (), b.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3703 + if (!ix) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3704 + x = galois (args(2).matrix_value (), b.m (), b.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3705 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3706 + if (nargin == 4) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3707 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3708 + if (!isi) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3709 + si = galois (args(3).matrix_value (), b.m (), b.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3710 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3711 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3712 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3713 + int a_len = a.numel (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3714 + int b_len = b.numel (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3715 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3716 + int si_len = (a_len > b_len ? a_len : b_len) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3717 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3718 + si = galois (si_len, 1, 0, b.m (), b.primpoly ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3719 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3720 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3721 + if ((b.m () != a.m ()) || (b.m () != x.m ()) || (b.m () != si.m ()) || |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3722 + (b.primpoly () != a.primpoly ()) || (b.primpoly () != x.primpoly ()) || |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3723 + (b.primpoly () != si.primpoly ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3724 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3725 + error ("gfilter: arguments must be in same galois field"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3726 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3727 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3728 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3729 + if (b.cols () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3730 + b = b.transpose (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3731 + if (a.cols () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3732 + a = a.transpose (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3733 + if (x.cols () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3734 + x = x.transpose (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3735 + if (si.cols () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3736 + si = si.transpose (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3737 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3738 + if (b.cols () > 1 || a.cols () > 1 || x.cols () > 1 || si.cols () > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3739 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3740 + error ("gfilter: arguments must be vectors"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3741 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3742 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3743 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3744 + galois y (filter (b, a, x, si)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3745 + if (nargout == 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3746 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3747 + if (si_is_row_vector) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3748 + retval(1) = new octave_galois (si.transpose ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3749 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3750 + retval(1) = new octave_galois (si); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3751 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3752 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3753 + if (x_is_row_vector) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3754 + retval(0) = new octave_galois (y.transpose ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3755 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3756 + retval(0) = new octave_galois (y); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3757 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3758 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3759 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3760 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3761 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3762 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3763 +%!error gfilter () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3764 +%!error gfilter (1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3765 +%!error gfilter (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3766 +%!error gfilter (1, 2, 3, 4, 5) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3767 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3768 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3769 +// PKG_ADD: autoload ("glu", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3770 +// PKG_DEL: autoload ("glu", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3771 +DEFUN_DLD (glu, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3772 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3773 +@deftypefn {Loadable Function} {[@var{l}, @var{u}, @var{p}] =} glu (@var{a})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3774 +@cindex LU decomposition of Galois matrix\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3775 +Compute the LU decomposition of @var{a} in a Galois Field. The result is\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3776 +returned in a permuted form, according to the optional return value\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3777 +@var{p}. For example, given the matrix\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3778 +@code{a = gf ([1, 2; 3, 4], 3)},\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3779 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3780 +@example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3781 +[l, u, p] = glu (a)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3782 +@end example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3783 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3784 +@noindent\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3785 +returns\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3786 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3787 +@example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3788 +l =\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3789 +GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3790 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3791 +Array elements =\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3792 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3793 + 1 0\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3794 + 6 1\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3795 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3796 +u =\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3797 +GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3798 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3799 +Array elements =\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3800 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3801 + 3 4\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3802 + 0 7\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3803 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3804 +p =\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3805 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3806 +Permutation Matrix\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3807 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3808 + 0 1\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3809 + 1 0\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3810 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3811 +@end example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3812 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3813 +Such that @code{@var{p} * @var{a} = @var{l} * @var{u}}. If the argument\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3814 +@var{p} is not included then the permutations are applied to @var{l}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3815 +so that @code{@var{a} = @var{l} * @var{u}}. @var{l} is then a pseudo-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3816 +lower triangular matrix. The matrix @var{a} can be rectangular.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3817 +@seealso{lu}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3818 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3819 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3820 + octave_value_list retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3821 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3822 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3823 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3824 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3825 + if (nargin != 1 || nargout > 3) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3826 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3827 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3828 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3829 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3830 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3831 + octave_value arg = args(0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3832 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3833 + if (!galois_type_loaded || (arg.type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3834 + octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3835 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3836 + err_wrong_type_arg ("glu", arg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3837 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3838 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3839 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3840 + galois m = ((const octave_galois&) arg.get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3841 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3842 + int nr = arg.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3843 + int nc = arg.columns (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3844 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3845 + int arg_is_empty = arg.isempty (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3846 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3847 + if (arg_is_empty < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3848 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3849 + else if (arg_is_empty > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3850 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3851 + retval(0) = new octave_galois (galois (0, 0, 0, m.m (), m.primpoly ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3852 + retval(1) = new octave_galois (galois (0, 0, 0, m.m (), m.primpoly ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3853 + retval(2) = new octave_galois (galois (0, 0, 0, m.m (), m.primpoly ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3854 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3855 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3856 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3857 + if (! error_state) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3858 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3859 + galoisLU fact (m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3860 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3861 + switch (nargout) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3862 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3863 + case 0: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3864 + case 1: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3865 + case 2: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3866 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3867 + // While we don't have sparse galois matrices converting the |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3868 + // permutation matrix to a full matrix is the best we can do. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3869 + Matrix P = Matrix (fact.P ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3870 + galois L = P.transpose () * fact.L (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3871 + retval(1) = new octave_galois (fact.U ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3872 + retval(0) = new octave_galois (L); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3873 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3874 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3875 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3876 + case 3: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3877 + default: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3878 + retval(2) = fact.P (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3879 + retval(1) = new octave_galois (fact.U ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3880 + retval(0) = new octave_galois (fact.L ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3881 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3882 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3883 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3884 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3885 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3886 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3887 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3888 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3889 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3890 +%!error glu () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3891 +%!error glu (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3892 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3893 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3894 +// PKG_ADD: autoload ("ginv", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3895 +// PKG_DEL: autoload ("ginv", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3896 +DEFUN_DLD (ginv, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3897 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3898 +@deftypefn {Loadable Function} {[@var{x}, @var{rcond}] =} ginv (@var{a})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3899 +Compute the inverse of the square matrix @var{a}. Return an estimate\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3900 +of the reciprocal condition number if requested, otherwise warn of an\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3901 +ill-conditioned matrix if the reciprocal condition number is small.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3902 +@seealso{inv}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3903 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3904 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3905 + octave_value_list retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3906 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3907 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3908 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3909 + if (nargin != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3910 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3911 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3912 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3913 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3914 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3915 + octave_value arg = args(0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3916 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3917 + int nr = arg.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3918 + int nc = arg.columns (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3919 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3920 + if (!galois_type_loaded || (arg.type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3921 + octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3922 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3923 + err_wrong_type_arg ("ginverse", arg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3924 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3925 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3926 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3927 + galois m = ((const octave_galois&) arg.get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3928 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3929 + int arg_is_empty = arg.isempty (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3930 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3931 + if (arg_is_empty < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3932 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3933 + else if (arg_is_empty > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3934 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3935 + retval(0) = new octave_galois (galois (0, 0, 0, m.m (), m.primpoly ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3936 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3937 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3938 + if (nr != nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3939 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3940 + err_square_matrix_required ("ginverse", "X"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3941 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3942 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3943 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3944 + if (! error_state) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3945 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3946 + int info; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3947 + double rcond = 0.0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3948 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3949 + galois result = m.inverse (info, 1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3950 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3951 + if (nargout > 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3952 + retval(1) = rcond; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3953 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3954 + retval(0) = new octave_galois (result); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3955 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3956 + if (nargout < 2 && info == -1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3957 + warning ("inverse: matrix singular to machine precision, rcond = %g", rcond); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3958 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3959 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3960 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3961 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3962 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3963 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3964 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3965 +%!error ginv () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3966 +%!error ginv (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3967 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3968 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3969 +// FIXME: this should really be done with an alias, but |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3970 +// alias_builtin() won't do the right thing if we are actually using |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3971 +// dynamic linking. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3972 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3973 +// PKG_ADD: autoload ("ginverse", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3974 +// PKG_DEL: autoload ("ginverse", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3975 +DEFUN_DLD (ginverse, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3976 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3977 +@deftypefn {Loadable Function} {} ginverse (@var{a})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3978 +Compute the inverse of the square matrix @var{a}. Return an estimate\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3979 +of the reciprocal condition number if requested, otherwise warn of an\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3980 +ill-conditioned matrix if the reciprocal condition number is small.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3981 +@seealso{ginv}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3982 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3983 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3984 + return Fginv (args, nargout); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3985 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3986 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3987 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3988 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3989 +%!error ginverse () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3990 +%!error ginverse (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3991 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3992 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3993 +// PKG_ADD: autoload ("gdet", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3994 +// PKG_DEL: autoload ("gdet", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3995 +DEFUN_DLD (gdet, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3996 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3997 +@deftypefn {Loadable Function} {@var{d} =} gdet (@var{a})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3998 +Compute the determinant of the Galois array @var{a}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3999 +@seealso{det}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4000 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4001 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4002 + octave_value retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4003 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4004 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4005 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4006 + if (nargin != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4007 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4008 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4009 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4010 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4011 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4012 + octave_value arg = args(0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4013 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4014 + if (!galois_type_loaded || (arg.type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4015 + octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4016 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4017 + err_wrong_type_arg ("gdet", arg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4018 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4019 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4020 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4021 + int nr = arg.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4022 + int nc = arg.columns (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4023 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4024 + galois m = ((const octave_galois&) arg.get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4025 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4026 + int arg_is_empty = arg.isempty (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4027 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4028 + if (arg_is_empty < 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4029 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4030 + else if (arg_is_empty > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4031 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4032 + retval = new octave_galois (galois (1, 1, 1, m.m (), m.primpoly ())); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4033 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4034 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4035 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4036 + if (nr != nc) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4037 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4038 + err_square_matrix_required ("det", "A"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4039 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4040 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4041 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4042 + retval = new octave_galois (m.determinant ()); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4043 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4044 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4045 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4046 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4047 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4048 +%!error gdet () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4049 +%!error gdet (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4050 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4051 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4052 +// PKG_ADD: autoload ("grank", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4053 +// PKG_DEL: autoload ("grank", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4054 +DEFUN_DLD (grank, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4055 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4056 +@deftypefn {Loadable Function} {@var{d} =} grank (@var{a})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4057 +Compute the rank of the Galois array @var{a} by counting the independent\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4058 +rows and columns.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4059 +@seealso{rank}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4060 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4061 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4062 + octave_value retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4063 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4064 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4065 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4066 + if (nargin != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4067 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4068 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4069 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4070 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4071 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4072 + octave_value arg = args(0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4073 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4074 + if (!galois_type_loaded || (arg.type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4075 + octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4076 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4077 + err_wrong_type_arg ("grank", arg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4078 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4079 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4080 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4081 + int nr = arg.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4082 + int nc = arg.columns (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4083 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4084 + galois m = ((const octave_galois&) arg.get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4085 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4086 + int arg_is_empty = arg.isempty (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4087 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4088 + if (arg_is_empty > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4089 + retval = 0.0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4090 + else if (arg_is_empty == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4091 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4092 + int d = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4093 + int mm = m.m (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4094 + int mn = m.n (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4095 + OCTAVE_LOCAL_BUFFER (int, ci, nr); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4096 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4097 + for (int i = 0; i < nc; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4098 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4099 + int idx = -1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4100 + int iel = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4101 + for (int j = 0; j < nr; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4102 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4103 + ci[j] = m.elem (j, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4104 + if (ci[j] != 0 && idx == -1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4105 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4106 + iel = ci[j]; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4107 + idx = j; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4108 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4109 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4110 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4111 + if (idx != -1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4112 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4113 + d++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4114 + int indx = m.index_of (iel); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4115 + for (int j = 0; j < nr; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4116 + if (ci[j] != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4117 + ci[j] = m.alpha_to (modn (m.index_of (ci[j]) - indx + mn, mm, mn)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4118 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4119 + for (int j = i+1; j < nc; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4120 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4121 + if (m.elem (idx, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4122 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4123 + indx = m.index_of (m.elem (idx, j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4124 + for (int k = 0; k < nr; k++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4125 + if (ci[k] != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4126 + m.elem (k, j) ^= m.alpha_to (modn (m.index_of (ci[k]) + indx + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4127 + mn, mm, mn)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4128 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4129 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4130 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4131 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4132 + retval = (double)d; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4133 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4134 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4135 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4136 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4137 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4138 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4139 +%!error grank () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4140 +%!error grank (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4141 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4142 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4143 +// PKG_ADD: autoload ("rsenc", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4144 +// PKG_DEL: autoload ("rsenc", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4145 +DEFUN_DLD (rsenc, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4146 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4147 +@deftypefn {Loadable Function} {@var{code} =} rsenc (@var{msg}, @var{n}, @var{k})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4148 +@deftypefnx {Loadable Function} {@var{code} =} rsenc (@var{msg}, @var{n}, @var{k}, @var{g})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4149 +@deftypefnx {Loadable Function} {@var{code} =} rsenc (@var{msg}, @var{n}, @var{k}, @var{fcr}, @var{prim})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4150 +@deftypefnx {Loadable Function} {@var{code} =} rsenc (@dots{}, @var{parpos})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4151 +Encodes the message @var{msg} using a [@var{n},@var{k}] Reed-Solomon coding.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4152 +The variable @var{msg} is a Galois array with @var{k} columns and an arbitrary\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4153 +number of rows. Each row of @var{msg} represents a single block to be coded\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4154 +by the Reed-Solomon coder. The coded message is returned in the Galois\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4155 +array @var{code} containing @var{n} columns and the same number of rows as\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4156 +@var{msg}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4157 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4158 +The use of @code{rsenc} can be seen in the following short example.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4159 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4160 +@example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4161 +m = 3; n = 2^m -1; k = 3;\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4162 +msg = gf ([1 2 3; 4 5 6], m);\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4163 +code = rsenc (msg, n, k);\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4164 +@end example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4165 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4166 +If @var{n} does not equal @code{2^@var{m}-1}, where m is an integer, then a\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4167 +shorten Reed-Solomon coding is used where zeros are added to the start of\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4168 +each row to obtain an allowable codeword length. The returned @var{code}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4169 +has these prepending zeros stripped.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4170 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4171 +By default the generator polynomial used in the Reed-Solomon coding is based\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4172 +on the properties of the Galois Field in which @var{msg} is given. This\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4173 +default generator polynomial can be overridden by a polynomial in @var{g}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4174 +Suitable generator polynomials can be constructed with @code{rsgenpoly}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4175 +@var{fcr} is an integer value, and it is taken to be the first consecutive\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4176 +root of the generator polynomial. The variable @var{prim} is then the\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4177 +primitive element used to construct the generator polynomial, such that\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4178 +@tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4179 +$g = (x - A^b) (x - A^{b+p}) \\cdots (x - A ^{b+2tp-1})$.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4180 +@end tex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4181 +@ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4182 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4183 +@var{g} = (@var{x} - A^@var{b}) * (@var{x} - A^(@var{b}+@var{prim})) * ... * (@var{x} - A^(@var{b}+2*@var{t}*@var{prim}-1)).\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4184 +@end ifnottex\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4185 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4186 +where @var{b} is equal to @code{@var{fcr} * @var{prim}}. By default @var{fcr}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4187 +and @var{prim} are both 1.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4188 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4189 +By default the parity symbols are placed at the end of the coded message.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4190 +The variable @var{parpos} controls this positioning and can take the values\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4191 +@code{\"beginning\"} or @code{\"end\"}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4192 +@seealso{gf, rsdec, rsgenpoly}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4193 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4194 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4195 + octave_value retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4196 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4197 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4198 + if (nargin < 3 || nargin > 5) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4199 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4200 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4201 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4202 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4203 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4204 + if (!galois_type_loaded || (args(0).type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4205 + octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4206 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4207 + err_wrong_type_arg ("rsenc", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4208 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4209 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4210 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4211 + galois msg = ((const octave_galois&) args(0).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4212 + int nsym = msg.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4213 + int primpoly = msg.primpoly (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4214 + int n = args(1).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4215 + int k = args(2).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4216 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4217 + int m = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4218 + while (n > (1<<m)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4219 + m++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4220 + int nn = (1<<m) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4221 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4222 + if (msg.cols () != k) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4223 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4224 + error ("rsenc: message contains incorrect number of symbols"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4225 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4226 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4227 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4228 + if (msg.m () != m) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4229 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4230 + error ("rsenc: message in incorrect galois field for codeword length"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4231 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4232 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4233 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4234 + if ((n < 3) || (n < k) || (m > __OCTAVE_GALOIS_MAX_M)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4235 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4236 + error ("rsenc: invalid values of message and codeword length"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4237 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4238 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4239 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4240 + if ((n-k) & 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4241 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4242 + error ("rsenc: difference of message and codeword length must be even"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4243 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4244 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4245 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4246 + int nroots = n-k; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4247 + galois genpoly; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4248 + bool have_genpoly = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4249 + bool parity_at_end = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4250 + int fcr = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4251 + int prim = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4252 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4253 + for (int i = 3; i < nargin; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4254 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4255 + if (args(i).is_string ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4256 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4257 + std::string parstr = args(i).string_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4258 + for (int j = 0; j < (int)parstr.length (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4259 + parstr[j] = toupper (parstr[j]); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4260 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4261 + if (!parstr.compare("END")) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4262 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4263 + parity_at_end = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4264 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4265 + else if (!parstr.compare("BEGINNING")) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4266 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4267 + parity_at_end = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4268 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4269 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4270 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4271 + error ("rsenc: unrecoginized parity position"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4272 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4273 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4274 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4275 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4276 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4277 + if (args(i).type_id () == octave_galois::static_type_id ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4278 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4279 + if (have_genpoly) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4280 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4281 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4282 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4283 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4284 + genpoly = ((const octave_galois&) args(i).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4285 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4286 + if (genpoly.cols () > genpoly.rows ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4287 + genpoly = genpoly.transpose (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4288 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4289 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4290 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4291 + if (have_genpoly) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4292 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4293 + if (prim != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4294 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4295 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4296 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4297 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4298 + prim = args(i).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4299 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4300 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4301 + fcr = args(i).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4302 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4303 + have_genpoly = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4304 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4305 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4306 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4307 + if ((genpoly.rows () == 0) || (genpoly.cols () == 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4308 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4309 + if (fcr == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4310 + fcr = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4311 + if (prim == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4312 + prim = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4313 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4314 + // Create polynomial of right length. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4315 + genpoly = galois (nroots+1, 1, 0, m, primpoly); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4316 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4317 + genpoly(nroots, 0) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4318 + int i, root; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4319 + for (i = 0, root=fcr*prim; i < nroots; i++, root += prim) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4320 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4321 + genpoly(nroots-i-1, 0) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4322 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4323 + // Multiply genpoly by @**(root + x) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4324 + for (int j = i; j > 0; j--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4325 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4326 + int k = nroots - j; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4327 + if (genpoly(k, 0) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4328 + genpoly(k, 0) = genpoly(k+1, 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4329 + ^ genpoly.alpha_to (modn (genpoly.index_of (genpoly(k, 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4330 + + root, m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4331 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4332 + genpoly(k, 0) = genpoly(k+1, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4333 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4334 + // genpoly(nroots,0) can never be zero |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4335 + genpoly(nroots, 0) = genpoly.alpha_to (modn (genpoly.index_of (genpoly(nroots, 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4336 + + root, m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4337 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4338 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4339 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4340 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4341 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4342 + if (genpoly.cols () != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4343 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4344 + error ("rsenc: the generator polynomial must be a vector"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4345 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4346 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4347 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4348 + if (genpoly.primpoly () != primpoly) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4349 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4350 + error ("rsenc: the generator polynomial must be same galois field " |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4351 + "as the message"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4352 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4353 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4354 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4355 + if (genpoly.rows () != nroots+1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4356 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4357 + error ("rsenc: generator polynomial has incorrect order"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4358 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4359 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4360 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4361 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4362 + int norm = genpoly(0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4363 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4364 + // Take logarithm of generator polynomial, for faster coding |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4365 + for (int i = 0; i < nroots+1; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4366 + genpoly(i, 0) = genpoly.index_of (genpoly(i, 0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4367 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4368 + // Add space for parity block |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4369 + msg.resize (dim_vector (nsym, n), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4370 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4371 + // The code below basically finds the parity bits by treating the |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4372 + // message as a polynomial and dividing it by the generator polynomial. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4373 + // The parity bits are then the remainder of this division. If the parity |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4374 + // is at the end the polynomial is treat MSB first, otherwise it is |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4375 + // treated LSB first |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4376 + // |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4377 + // This code could just as easily be written as |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4378 + // [ignore par] = gdeconv(msg, genpoly); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4379 + // But the code below has the advantage of being 20 times faster :-) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4380 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4381 + if (parity_at_end) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4382 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4383 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4384 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4385 + galois par (nroots, 1, 0, m, primpoly); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4386 + for (int i = 0; i < k; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4387 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4388 + int feedback = par.index_of (par(0, 0) ^ msg(l, i)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4389 + if (feedback != nn) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4390 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4391 + if (norm != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4392 + feedback = modn (nn-genpoly(0, 0)+feedback, m, nn); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4393 + for (int j = 1; j < nroots; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4394 + par(j, 0) ^= par.alpha_to (modn (feedback + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4395 + genpoly(j, 0), m, nn)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4396 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4397 + for (int j = 1; j < nroots; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4398 + par(j-1, 0) = par(j, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4399 + if (feedback != nn) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4400 + par(nroots-1, 0) = par.alpha_to (modn (feedback+ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4401 + genpoly(nroots, 0), m, nn)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4402 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4403 + par(nroots-1, 0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4404 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4405 + for (int j = 0; j < nroots; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4406 + msg(l, k+j) = par(j, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4407 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4408 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4409 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4410 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4411 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4412 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4413 + for (int i=k; i > 0; i--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4414 + msg(l, i+nroots-1) = msg(l, i-1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4415 + for (int i = 0; i<nroots; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4416 + msg(l, i) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4417 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4418 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4419 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4420 + galois par (nroots, 1, 0, m, primpoly); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4421 + for (int i = n; i > nroots; i--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4422 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4423 + int feedback = par.index_of (par(0, 0) ^ msg(l, i-1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4424 + if (feedback != nn) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4425 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4426 + if (norm != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4427 + feedback = modn (nn-genpoly(0, 0)+feedback, m, nn); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4428 + for (int j = 1; j < nroots; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4429 + par(j, 0) ^= par.alpha_to (modn (feedback + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4430 + genpoly(j, 0), m, nn)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4431 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4432 + for (int j = 1; j < nroots; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4433 + par(j-1, 0) = par(j, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4434 + if (feedback != nn) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4435 + par(nroots-1, 0) = par.alpha_to (modn (feedback+ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4436 + genpoly(nroots, 0), m, nn)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4437 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4438 + par(nroots-1, 0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4439 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4440 + for (int j = 0; j < nroots; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4441 + msg(l, j) = par(nroots-j-1, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4442 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4443 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4444 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4445 + retval = new octave_galois (msg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4446 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4447 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4448 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4449 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4450 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4451 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4452 +%!error rsenc () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4453 +%!error rsenc (1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4454 +%!error rsenc (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4455 +%!error rsenc (1, 2, 3, 4, 5, 6) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4456 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4457 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4458 +int |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4459 +decode_rs(galois& data, const int prim, const int iprim, const int nroots, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4460 + const int fcr, const int drow, const bool msb_first) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4461 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4462 + int deg_lambda, el, deg_omega; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4463 + int i, j, r, k; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4464 + int q, tmp, num1, num2, den, discr_r; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4465 + int syn_error, count; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4466 + int m = data.m (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4467 + int n = data.n (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4468 + int A0 = n; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4469 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4470 + /* Err Locator and syndrome poly */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4471 + OCTAVE_LOCAL_BUFFER (int, lambda, nroots+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4472 + OCTAVE_LOCAL_BUFFER (int, s, nroots); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4473 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4474 + OCTAVE_LOCAL_BUFFER (int, b, nroots+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4475 + OCTAVE_LOCAL_BUFFER (int, t, nroots+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4476 + OCTAVE_LOCAL_BUFFER (int, omega, nroots+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4477 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4478 + OCTAVE_LOCAL_BUFFER (int, root, nroots); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4479 + OCTAVE_LOCAL_BUFFER (int, reg, nroots+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4480 + OCTAVE_LOCAL_BUFFER (int, loc, nroots); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4481 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4482 + /* form the syndromes; i.e., evaluate data(x) at roots of g(x) */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4483 + if (msb_first) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4484 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4485 + for (i = 0; i < nroots; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4486 + s[i] = data(drow, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4487 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4488 + for (j = 1; j < n; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4489 + for (i = 0; i<nroots; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4490 + if(s[i] == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4491 + s[i] = data(drow, j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4492 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4493 + s[i] = data(drow, j) ^ data.alpha_to (modn (data.index_of (s[i]) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4494 + (fcr+i)*prim, m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4495 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4496 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4497 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4498 + for (i = 0; i<nroots; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4499 + s[i] = data(drow, n-1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4500 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4501 + for (j = n-1; j>0; j--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4502 + for (i = 0; i < nroots; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4503 + if(s[i] == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4504 + s[i] = data(drow, j-1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4505 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4506 + s[i] = data(drow, j-1) ^ data.alpha_to (modn (data.index_of (s[i]) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4507 + (fcr+i)*prim, m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4508 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4509 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4510 + /* Convert syndromes to index form, checking for nonzero condition */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4511 + syn_error = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4512 + for (i = 0; i < nroots; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4513 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4514 + syn_error |= s[i]; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4515 + s[i] = data.index_of (s[i]); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4516 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4517 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4518 + if (!syn_error) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4519 + /* if syndrome is zero, data(drow,:) is a codeword and there are no |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4520 + * errors to correct. So return data(drow,:) unmodified |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4521 + */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4522 + return 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4523 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4524 + memset(&lambda[1], 0, nroots*sizeof (lambda[0])); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4525 + lambda[0] = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4526 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4527 + for (i = 0; i < nroots+1; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4528 + b[i] = data.index_of (lambda[i]); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4529 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4530 + /* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4531 + * Begin Berlekamp-Massey algorithm to determine error locator polynomial |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4532 + */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4533 + r = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4534 + el = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4535 + while (++r <= nroots) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4536 + {/* r is the step number */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4537 + /* Compute discrepancy at the r-th step in poly-form */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4538 + discr_r = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4539 + for (i = 0; i < r; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4540 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4541 + if ((lambda[i] != 0) && (s[r-i-1] != A0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4542 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4543 + discr_r ^= data.alpha_to (modn (data.index_of (lambda[i]) + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4544 + s[r-i-1], m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4545 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4546 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4547 + discr_r = data.index_of (discr_r); /* Index form */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4548 + if (discr_r == A0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4549 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4550 + /* 2 lines below: B(x) <-- x*B(x) */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4551 + memmove(&b[1], b, nroots*sizeof (b[0])); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4552 + b[0] = A0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4553 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4554 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4555 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4556 + /* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4557 + t[0] = lambda[0]; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4558 + for (i = 0 ; i < nroots; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4559 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4560 + if(b[i] != A0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4561 + t[i+1] = lambda[i+1] ^ data.alpha_to (modn (discr_r + b[i], m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4562 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4563 + t[i+1] = lambda[i+1]; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4564 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4565 + if (2 * el <= r - 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4566 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4567 + el = r - el; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4568 + /* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4569 + * 2 lines below: B(x) <-- inv(discr_r) * |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4570 + * lambda(x) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4571 + */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4572 + for (i = 0; i <= nroots; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4573 + b[i] = (lambda[i] == 0) ? A0 : modn (data.index_of (lambda[i]) - |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4574 + discr_r + n, m, n); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4575 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4576 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4577 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4578 + /* 2 lines below: B(x) <-- x*B(x) */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4579 + memmove(&b[1], b, nroots*sizeof (b[0])); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4580 + b[0] = A0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4581 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4582 + memcpy(lambda, t, (nroots+1)*sizeof (t[0])); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4583 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4584 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4585 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4586 + /* Convert lambda to index form and compute deg(lambda(x)) */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4587 + deg_lambda = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4588 + for (i = 0; i < nroots+1; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4589 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4590 + lambda[i] = data.index_of (lambda[i]); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4591 + if(lambda[i] != A0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4592 + deg_lambda = i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4593 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4594 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4595 + /* Find roots of the error locator polynomial by Chien search */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4596 + memcpy(®[1], &lambda[1], nroots*sizeof (reg[0])); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4597 + count = 0; /* Number of roots of lambda(x) */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4598 + for (i = 1, k = iprim-1; i <= n; i++, k = modn (k+iprim, m, n)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4599 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4600 + q = 1; /* lambda[0] is always 0 */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4601 + for (j = deg_lambda; j > 0; j--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4602 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4603 + if (reg[j] != A0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4604 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4605 + reg[j] = modn (reg[j] + j, m, n); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4606 + q ^= data.alpha_to (reg[j]); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4607 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4608 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4609 + if (q != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4610 + continue; /* Not a root */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4611 + /* store root (index-form) and error location number */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4612 + root[count] = i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4613 + loc[count] = k; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4614 + /* If we've already found max possible roots, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4615 + * abort the search to save time |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4616 + */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4617 + if(++count == deg_lambda) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4618 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4619 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4620 + if (deg_lambda != count) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4621 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4622 + /* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4623 + * deg(lambda) unequal to number of roots => uncorrectable |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4624 + * error detected |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4625 + */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4626 + return -1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4627 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4628 + /* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4629 + * Compute err evaluator poly omega(x) = s(x)*lambda(x) (modulo |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4630 + * x**nroots). in index form. Also find deg(omega). |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4631 + */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4632 + deg_omega = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4633 + for (i = 0; i < nroots; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4634 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4635 + tmp = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4636 + j = (deg_lambda < i) ? deg_lambda : i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4637 + for (; j >= 0; j--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4638 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4639 + if ((s[i - j] != A0) && (lambda[j] != A0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4640 + tmp ^= data.alpha_to (modn (s[i - j] + lambda[j], m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4641 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4642 + if(tmp != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4643 + deg_omega = i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4644 + omega[i] = data.index_of (tmp); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4645 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4646 + omega[nroots] = A0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4647 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4648 + /* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4649 + * Compute error values in poly-form. num1 = omega(inv(X(l))), num2 = |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4650 + * inv(X(l))**(fcr-1) and den = lambda_pr(inv(X(l))) all in poly-form |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4651 + */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4652 + for (j = count-1; j >= 0; j--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4653 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4654 + num1 = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4655 + for (i = deg_omega; i >= 0; i--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4656 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4657 + if (omega[i] != A0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4658 + num1 ^= data.alpha_to (modn (omega[i] + i * root[j], m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4659 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4660 + num2 = data.alpha_to (modn (root[j] * (fcr - 1) + n, m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4661 + den = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4662 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4663 + /* lambda[i+1] for i even is the formal deriv lambda_pr of lambda[i] */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4664 + for (i = (deg_lambda < nroots-1 ? deg_lambda : nroots-1) & ~1; i >= 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4665 + i -=2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4666 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4667 + if(lambda[i+1] != A0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4668 + den ^= data.alpha_to (modn (lambda[i+1] + i * root[j], m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4669 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4670 + if (den == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4671 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4672 + count = -1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4673 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4674 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4675 + /* Apply error to data */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4676 + if (num1 != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4677 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4678 + if (msb_first) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4679 + data(drow, loc[j]) ^= data.alpha_to (modn (data.index_of (num1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4680 + + data.index_of (num2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4681 + + n - data.index_of (den), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4682 + m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4683 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4684 + data(drow, n-loc[j]-1) ^= data.alpha_to (modn (data.index_of (num1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4685 + + data.index_of (num2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4686 + + n - data.index_of (den), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4687 + m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4688 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4689 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4690 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4691 + return count; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4692 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4693 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4694 +// PKG_ADD: autoload ("rsdec", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4695 +// PKG_DEL: autoload ("rsdec", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4696 +DEFUN_DLD (rsdec, args, nargout, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4697 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4698 +@deftypefn {Loadable Function} {@var{msg} =} rsdec (@var{code}, @var{n}, @var{k})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4699 +@deftypefnx {Loadable Function} {@var{msg} =} rsdec (@var{code}, @var{n}, @var{k}, @var{g})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4700 +@deftypefnx {Loadable Function} {@var{msg} =} rsdec (@var{code}, @var{n}, @var{k}, @var{fcr}, @var{prim})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4701 +@deftypefnx {Loadable Function} {@var{msg} =} rsdec (@dots{}, @var{parpos})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4702 +@deftypefnx {Loadable Function} {[@var{msg}, @var{nerr}] =} rsdec (@dots{})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4703 +@deftypefnx {Loadable Function} {[@var{msg}, @var{nerr}, @var{ccode}] =} rsdec (@dots{})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4704 +Decodes the message contained in @var{code} using a [@var{n},@var{k}]\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4705 +Reed-Solomon code. The variable @var{code} must be a Galois array with\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4706 +@var{n} columns and an arbitrary number of rows. Each row of @var{code}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4707 +represents a single block to be decoded by the Reed-Solomon coder. The\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4708 +decoded message is returned in the variable @var{msg} containing @var{k}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4709 +columns and the same number of rows as @var{code}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4710 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4711 +If @var{n} does not equal @code{2^@var{m}-1}, where m is an integer, then a\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4712 +shorten Reed-Solomon decoding is used where zeros are added to the start of\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4713 +each row to obtain an allowable codeword length. The returned @var{msg}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4714 +has these prepending zeros stripped.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4715 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4716 +By default the generator polynomial used in the Reed-Solomon coding is based\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4717 +on the properties of the Galois Field in which @var{msg} is given. This\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4718 +default generator polynomial can be overridden by a polynomial in @var{g}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4719 +Suitable generator polynomials can be constructed with @code{rsgenpoly}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4720 +@var{fcr} is an integer value, and it is taken to be the first consecutive\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4721 +root of the generator polynomial. The variable @var{prim} is then the\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4722 +primitive element used to construct the generator polynomial. By default\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4723 +@var{fcr} and @var{prim} are both 1. It is significantly faster to specify\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4724 +the generator polynomial in terms of @var{fcr} and @var{prim}, since @var{g}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4725 +is converted to this form in any case.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4726 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4727 +By default the parity symbols are placed at the end of the coded message.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4728 +The variable @var{parpos} controls this positioning and can take the values\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4729 +@code{\"beginning\"} or @code{\"end\"}. If the parity symbols are at the end, the message is\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4730 +treated with the most-significant symbol first, otherwise the message is\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4731 +treated with the least-significant symbol first.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4732 +@seealso{gf, rsenc, rsgenpoly}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4733 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4734 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4735 + octave_value_list retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4736 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4737 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4738 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4739 + if (nargin < 3 || nargin > 5) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4740 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4741 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4742 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4743 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4744 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4745 + if (!galois_type_loaded || (args(0).type_id () != |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4746 + octave_galois::static_type_id ())) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4747 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4748 + err_wrong_type_arg ("rsdec", args(0)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4749 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4750 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4751 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4752 + galois code = ((const octave_galois&) args(0).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4753 + int nsym = code.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4754 + int primpoly = code.primpoly (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4755 + int n = args(1).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4756 + int k = args(2).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4757 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4758 + int m = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4759 + while (n > (1<<m)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4760 + m++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4761 + int nn = (1<<m) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4762 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4763 + if (code.cols () != n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4764 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4765 + error ("rsdec: coded message contains incorrect number of symbols"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4766 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4767 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4768 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4769 + if (code.m () != m) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4770 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4771 + error ("rsdec: coded message in incorrect galois field for " |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4772 + "codeword length"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4773 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4774 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4775 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4776 + if ((n < 3) || (n < k) || (m > __OCTAVE_GALOIS_MAX_M)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4777 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4778 + error ("rsdec: invalid values of message and codeword length"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4779 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4780 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4781 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4782 + if ((n-k) & 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4783 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4784 + error ("rsdec: difference of message and codeword length must be even"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4785 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4786 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4787 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4788 + int nroots = n-k; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4789 + galois genpoly; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4790 + bool have_genpoly = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4791 + bool parity_at_end = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4792 + int fcr = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4793 + int prim = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4794 + int iprim; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4795 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4796 + for (int i = 3; i < 6; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4797 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4798 + if (nargin > i) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4799 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4800 + if (args(i).is_string ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4801 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4802 + std::string parstr = args(i).string_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4803 + for (int j = 0; j < (int)parstr.length (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4804 + parstr[j] = toupper (parstr[j]); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4805 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4806 + if (!parstr.compare("END")) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4807 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4808 + parity_at_end = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4809 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4810 + else if (!parstr.compare("BEGINNING")) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4811 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4812 + parity_at_end = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4813 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4814 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4815 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4816 + error ("rsdec: unrecoginized parrity position"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4817 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4818 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4819 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4820 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4821 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4822 + if (args(i).type_id () == octave_galois::static_type_id ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4823 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4824 + if (have_genpoly) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4825 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4826 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4827 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4828 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4829 + genpoly = ((const octave_galois&) args(i).get_rep ()).galois_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4830 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4831 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4832 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4833 + if (have_genpoly) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4834 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4835 + if (prim != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4836 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4837 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4838 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4839 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4840 + prim = args(i).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4841 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4842 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4843 + fcr = args(i).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4844 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4845 + have_genpoly = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4846 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4847 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4848 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4849 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4850 + if (have_genpoly) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4851 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4852 + if (fcr != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4853 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4854 + if ((fcr < 1) || (fcr > nn)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4855 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4856 + error ("rsdec: invalid first consecutive root of generator polynomial"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4857 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4858 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4859 + if ((prim < 1) || (prim > nn)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4860 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4861 + error ("rsdec: invalid primitive element of generator polynomial"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4862 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4863 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4864 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4865 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4866 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4867 + if (genpoly.cols () > genpoly.rows ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4868 + genpoly = genpoly.transpose (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4869 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4870 + if (genpoly.cols () != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4871 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4872 + error ("rsdec: the generator polynomial must be a vector"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4873 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4874 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4875 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4876 + if (genpoly.primpoly () != primpoly) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4877 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4878 + error ("rsdec: the generator polynomial must be same galois " |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4879 + "field as the message"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4880 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4881 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4882 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4883 + if (genpoly.rows () != nroots+1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4884 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4885 + error ("rsdec: generator polynomial has incorrect order"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4886 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4887 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4888 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4889 + // Find the roots of the generator polynomial |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4890 + int count = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4891 + OCTAVE_LOCAL_BUFFER (int, roots, nroots); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4892 + for (int j = 0; j <= nn; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4893 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4894 + // Evaluate generator polynomial at j |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4895 + int val = genpoly(0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4896 + int indx = genpoly.index_of (j); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4897 + for (int i = 0; i<nroots; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4898 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4899 + if (val == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4900 + val = genpoly(i+1, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4901 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4902 + val = genpoly(i+1, 0) ^ genpoly.alpha_to (modn (indx + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4903 + genpoly.index_of (val), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4904 + m, nn)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4905 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4906 + if (val == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4907 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4908 + roots[count] = j; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4909 + count++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4910 + if (count == nroots) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4911 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4912 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4913 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4914 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4915 + if (count != nroots) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4916 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4917 + error ("rsdec: generator polynomial can not have repeated roots"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4918 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4919 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4920 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4921 + // Logarithm of roots wrt primitive element |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4922 + for (int i = 0; i < count; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4923 + roots[i] = genpoly.index_of (roots[i]); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4924 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4925 + // Find a corresponding fcr and prim that coincide with the roots. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4926 + // FIXME: This is a naive algorithm and should be improved !!! |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4927 + bool found = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4928 + for (fcr = 1; fcr < n+1; fcr++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4929 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4930 + for (prim = 1; prim < n+1; prim++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4931 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4932 + found = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4933 + for (int i = 0; i<nroots; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4934 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4935 + int tmp = modn ((fcr + i)*prim, m, n); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4936 + for (int j = 0; j<count; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4937 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4938 + if (tmp == roots[j]) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4939 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4940 + tmp = -1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4941 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4942 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4943 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4944 + if (tmp != -1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4945 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4946 + found = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4947 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4948 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4949 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4950 + if (found) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4951 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4952 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4953 + if (found) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4954 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4955 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4956 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4957 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4958 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4959 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4960 + fcr = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4961 + prim = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4962 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4963 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4964 + /* Find prim-th root of 1, used in decoding */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4965 + for (iprim = 1; (iprim % prim) != 0; iprim += n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4966 + ; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4967 + iprim = iprim / prim; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4968 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4969 + galois msg (nsym, k, 0, m, primpoly); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4970 + ColumnVector nerr (nsym, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4971 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4972 + if (nn != n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4973 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4974 + code.resize (dim_vector (nsym, nn), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4975 + if (parity_at_end) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4976 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4977 + for (int i=n; i > 0; i--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4978 + code(l, i+nn-n-1) = code(l, i-1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4979 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4980 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4981 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4982 + nerr(l) = decode_rs (code, prim, iprim, nroots, fcr, l, parity_at_end); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4983 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4984 + if (nn != n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4985 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4986 + if (parity_at_end) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4987 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4988 + for (int i = 0; i > n; i--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4989 + code(l, i) = code(l, i+nn-n); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4990 + code.resize (dim_vector (nsym, n), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4991 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4992 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4993 + if (parity_at_end) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4994 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4995 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4996 + for (int i = 0; i < k; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4997 + msg(l, i) = code(l, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4998 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4999 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5000 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5001 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5002 + for (int i = 0; i < k; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5003 + msg(l, i) = code(l, nroots+i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5004 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5005 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5006 + retval(0) = new octave_galois (msg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5007 + retval(1) = octave_value (nerr); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5008 + retval(2) = new octave_galois (code); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5009 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5010 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5011 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5012 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5013 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5014 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5015 +%!error rsdec () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5016 +%!error rsdec (1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5017 +%!error rsdec (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5018 +%!error rsdec (1, 2, 3, 4, 5, 6) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5019 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5020 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5021 +// PKG_ADD: autoload ("bchenco", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5022 +// PKG_DEL: autoload ("bchenco", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5023 +DEFUN_DLD (bchenco, args, , |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5024 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5025 +@deftypefn {Loadable Function} {@var{code} =} bchenco (@var{msg}, @var{n}, @var{k})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5026 +@deftypefnx {Loadable Function} {@var{code} =} bchenco (@var{msg}, @var{n}, @var{k}, @var{g})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5027 +@deftypefnx {Loadable Function} {@var{code} =} bchenco (@dots{}, @var{parpos})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5028 +Encodes the message @var{msg} using a [@var{n},@var{k}] BCH coding.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5029 +The variable @var{msg} is a binary array with @var{k} columns and an\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5030 +arbitrary number of rows. Each row of @var{msg} represents a single symbol\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5031 +to be coded by the BCH coder. The coded message is returned in the binary\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5032 +array @var{code} containing @var{n} columns and the same number of rows as\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5033 +@var{msg}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5034 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5035 +The use of @code{bchenco} can be seen in the following short example.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5036 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5037 +@example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5038 +m = 3; n = 2^m -1; k = 4;\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5039 +msg = randint (10,k);\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5040 +code = bchenco (msg, n, k);\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5041 +@end example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5042 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5043 +Valid codes can be found using @code{bchpoly}. In general the codeword\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5044 +length @var{n} should be of the form @code{2^@var{m}-1}, where m is an\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5045 +integer. However, shortened BCH codes can be used such that if\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5046 +@code{[2^@var{m}-1,@var{k}]} is a valid code\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5047 +@code{[2^@var{m}-1-@var{x},@var{k}-@var{x}]}\n is also a valid code using\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5048 +the same generator polynomial.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5049 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5050 +By default the generator polynomial used in the BCH coding is\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5051 +based on the properties of the Galois Field GF(2^@var{m}). This\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5052 +default generator polynomial can be overridden by a polynomial in @var{g}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5053 +Suitable generator polynomials can be constructed with @code{bchpoly}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5054 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5055 +By default the parity symbols are placed at the beginning of the coded\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5056 +message. The variable @var{parpos} controls this positioning and can take\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5057 +the values @code{\"beginning\"} or @code{\"end\"}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5058 +@seealso{bchpoly, bchdeco, encode}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5059 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5060 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5061 + octave_value retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5062 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5063 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5064 + if (nargin < 3 || nargin > 5) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5065 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5066 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5067 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5068 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5069 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5070 + Matrix msg = args(0).matrix_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5071 + int nsym = msg.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5072 + int nn = args(1).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5073 + int k = args(2).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5074 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5075 + int m = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5076 + while (nn > (1<<m)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5077 + m++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5078 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5079 + int n = (1<<m) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5080 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5081 + if (msg.cols () != k) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5082 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5083 + error ("bchenco: message contains incorrect number of symbols"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5084 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5085 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5086 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5087 + if ((n < 3) || (nn < k) || (m > __OCTAVE_GALOIS_MAX_M)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5088 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5089 + error ("bchenco: invalid values of message or codeword length"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5090 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5091 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5092 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5093 + galois genpoly; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5094 + bool have_genpoly = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5095 + bool parity_at_end = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5096 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5097 + for (int i = 3; i < nargin; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5098 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5099 + if (args(i).is_string ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5100 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5101 + std::string parstr = args(i).string_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5102 + for (int j = 0; j < (int)parstr.length (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5103 + parstr[j] = toupper (parstr[j]); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5104 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5105 + if (!parstr.compare("END")) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5106 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5107 + parity_at_end = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5108 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5109 + else if (!parstr.compare("BEGINNING")) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5110 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5111 + parity_at_end = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5112 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5113 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5114 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5115 + error ("bchenco: unrecoginized parity position"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5116 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5117 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5118 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5119 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5120 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5121 + have_genpoly = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5122 + genpoly = galois (args(i).matrix_value (), m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5123 + if (genpoly.cols () > genpoly.rows ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5124 + genpoly = genpoly.transpose (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5125 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5126 + if (genpoly.cols () != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5127 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5128 + error ("bchenco: the generator polynomial must be a vector"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5129 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5130 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5131 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5132 + if (genpoly.rows () != nn-k+1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5133 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5134 + error ("bchenco: generator polynomial has incorrect order"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5135 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5136 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5137 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5138 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5139 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5140 + if (!have_genpoly) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5141 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5142 + // The code below is basically bchpoly.m in C++, so if there is a need |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5143 + // it can be used to rewrite bchpoly as an oct-file... |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5144 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5145 + RowVector found (n, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5146 + found(0) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5147 + galois c (1, m, 0, m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5148 + c(0, 0) = c.index_of (1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5149 + Array<int> cs (dim_vector (1, 1), 1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5150 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5151 + int nc = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5152 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5153 + // Find the cyclotomic cosets of GF(2^m) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5154 + while (found.min () == 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5155 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5156 + int idx = n; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5157 + for (int i = 0; i<n; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5158 + if ((found(i) == 0) && (c.index_of (i+1) < idx)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5159 + idx = c.index_of (i+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5160 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5161 + c.resize (dim_vector (nc+1, m)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5162 + cs.resize (dim_vector (nc+1, 1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5163 + c(nc, 0) = idx; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5164 + found(c.alpha_to (idx)-1) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5165 + cs(nc) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5166 + int r = idx; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5167 + while ((r = modn (r<<1, m, n)) > idx) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5168 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5169 + c(nc, cs(nc)) = r; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5170 + found(c.alpha_to (r)-1) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5171 + cs(nc) += 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5172 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5173 + nc++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5174 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5175 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5176 + // Re-use the found vector with 1==not-found !!! |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5177 + found.resize (nc); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5178 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5179 + galois f (1, 0, 0, m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5180 + int t = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5181 + int nf = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5182 + do |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5183 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5184 + t++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5185 + for (int i = 0; i < nc; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5186 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5187 + if (found(i) == 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5188 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5189 + for (int j = 2*(t-1); j<2*t; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5190 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5191 + int flag = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5192 + for (int l = 0; l < cs(i); l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5193 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5194 + if (c(i, l) == j+1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5195 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5196 + f.resize (dim_vector (1, nf+cs(i))); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5197 + for (int ll = 0; ll < cs(i); ll++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5198 + f(0, nf+ll) = c(i, ll); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5199 + found(i) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5200 + nf += cs(i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5201 + flag = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5202 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5203 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5204 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5205 + if (flag) break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5206 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5207 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5208 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5209 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5210 + while (nf < nn - k); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5211 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5212 + if (nf != nn - k) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5213 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5214 + error ("bchenco: can not find valid generator polynomial for parameters"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5215 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5216 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5217 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5218 + // Create polynomial of right length. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5219 + genpoly = galois (nf+1, 1, 0, m); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5220 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5221 + genpoly(0, 0) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5222 + for (int i = 0; i < nf; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5223 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5224 + genpoly(i+1, 0) = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5225 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5226 + // Multiply genpoly by @**(root + x) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5227 + for (int l = i; l > 0; l--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5228 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5229 + if (genpoly(l, 0) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5230 + genpoly(l, 0) = genpoly(l-1, 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5231 + ^ genpoly.alpha_to (modn (genpoly.index_of (genpoly(l, 0)) + f(0, i), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5232 + m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5233 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5234 + genpoly(l, 0) = genpoly(l-1, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5235 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5236 + // genpoly(0,0) can never be zero |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5237 + genpoly(0, 0) = genpoly.alpha_to (modn (genpoly.index_of (genpoly(0, 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5238 + + f(0, i), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5239 + m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5240 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5241 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5242 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5243 + // Add space for parity block |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5244 + msg.resize (nsym, nn, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5245 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5246 + // The code below basically finds the parity bits by treating the |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5247 + // message as a polynomial and dividing it by the generator polynomial. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5248 + // The parity bits are then the remainder of this division. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5249 + // |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5250 + // This code could just as easily be written as |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5251 + // [ignore par] = gdeconv(gf(msg), gf(genpoly)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5252 + // But the code below has the advantage of being 20 times faster :-) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5253 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5254 + if (parity_at_end) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5255 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5256 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5257 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5258 + for (int i = 0; i < k; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5259 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5260 + int feedback = (int)msg(l, i) ^ (int)msg(l, k); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5261 + if (feedback != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5262 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5263 + for (int j = 0; j < nn-k-1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5264 + if (genpoly(nn-k-j-1, 0) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5265 + msg(l, k+j) = (int)msg(l, k+j+1) ^ feedback; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5266 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5267 + msg(l, k+j) = msg(l, k+j+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5268 + msg(l, nn-1) = genpoly(0, 0) & feedback; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5269 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5270 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5271 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5272 + for (int j = k; j < nn-1; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5273 + msg(l, j) = msg(l, j+1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5274 + msg(l, nn-1) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5275 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5276 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5277 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5278 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5279 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5280 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5281 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5282 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5283 + for (int i=k; i > 0; i--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5284 + msg(l, i+nn-k-1) = msg(l, i-1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5285 + for (int i = 0; i<nn-k; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5286 + msg(l, i) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5287 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5288 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5289 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5290 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5291 + for (int i = k-1; i >= 0; i--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5292 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5293 + int feedback = (int)msg(l, nn-k+i) ^ (int)msg(l, nn-k-1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5294 + if (feedback != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5295 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5296 + for (int j = nn - k -1; j > 0; j--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5297 + if (genpoly(j, 0) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5298 + msg(l, j) = (int)msg(l, j-1) ^ feedback; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5299 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5300 + msg(l, j) = msg(l, j-1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5301 + msg(l, 0) = genpoly(0, 0) & feedback; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5302 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5303 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5304 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5305 + for (int j = nn - k - 1; j > 0; j--) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5306 + msg(l, j) = msg(l, j-1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5307 + msg(l, 0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5308 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5309 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5310 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5311 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5312 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5313 + retval = msg; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5314 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5315 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5316 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5317 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5318 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5319 +%!error bchenco () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5320 +%!error bchenco (1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5321 +%!error bchenco (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5322 +%!error bchenco (1, 2, 3, 4, 5, 6) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5323 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5324 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5325 +// PKG_ADD: autoload ("bchdeco", "gf.oct"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5326 +// PKG_DEL: autoload ("bchdeco", "gf.oct", "remove"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5327 +DEFUN_DLD (bchdeco, args, , |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5328 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5329 +@deftypefn {Loadable Function} {@var{msg} =} bchdeco (@var{code}, @var{k}, @var{t})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5330 +@deftypefnx {Loadable Function} {@var{msg} =} bchdeco (@var{code}, @var{k}, @var{t}, @var{prim})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5331 +@deftypefnx {Loadable Function} {@var{msg} =} bchdeco (@dots{}, @var{parpos})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5332 +@deftypefnx {Loadable Function} {[@var{msg}, @var{err}] =} bchdeco (@dots{})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5333 +@deftypefnx {Loadable Function} {[@var{msg}, @var{err}, @var{ccode}] =} bchdeco (@dots{})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5334 +Decodes the coded message @var{code} using a BCH coder. The message length\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5335 +of the coder is defined in variable @var{k}, and the error correction\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5336 +capability of the code is defined in @var{t}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5337 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5338 +The variable @var{code} is a binary array with @var{n} columns and an\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5339 +arbitrary number of rows. Each row of @var{code} represents a single symbol\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5340 +to be decoded by the BCH coder. The decoded message is returned in the\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5341 +binary array @var{msg} containing @var{k} columns and the same number of\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5342 +rows as @var{code}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5343 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5344 +The use of @code{bchdeco} can be seen in the following short example.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5345 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5346 +@example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5347 +m = 3; n = 2^m -1; k = 4; t = 1;\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5348 +msg = randint (10, k);\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5349 +code = bchenco (msg, n, k);\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5350 +noisy = mod (randerr (10,n) + code, 2);\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5351 +[dec, err] = bchdeco (msg, k, t);\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5352 +@end example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5353 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5354 +Valid codes can be found using @code{bchpoly}. In general the codeword\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5355 +length @var{n} should be of the form @code{2^@var{m}-1}, where m is an\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5356 +integer. However, shortened BCH codes can be used such that if\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5357 +@code{[2^@var{m}-1,@var{k}]} is a valid code\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5358 +@code{[2^@var{m}-1-@var{x},@var{k}-@var{x}]}\n is also a valid code using\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5359 +the same generator polynomial.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5360 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5361 +By default the BCH coding is based on the properties of the Galois\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5362 +Field GF(2^@var{m}). The primitive polynomial used in the Galois\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5363 +can be overridden by a primitive polynomial in @var{prim}. Suitable\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5364 +primitive polynomials can be constructed with @code{primpoly}. The form\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5365 +of @var{prim} maybe be either a integer representation of the primitive\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5366 +polynomial as given by @code{primpoly}, or a binary representation that\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5367 +might be constructed like\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5368 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5369 +@example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5370 +m = 3;\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5371 +prim = de2bi (primpoly (m));\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5372 +@end example\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5373 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5374 +By default the parity symbols are assumed to be placed at the beginning of\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5375 +the coded message. The variable @var{parpos} controls this positioning and\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5376 +can take the values @code{\"beginning\"} or @code{\"end\"}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5377 +@seealso{bchpoly, bchenco, decode, primpoly}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5378 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5379 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5380 + octave_value_list retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5381 + int nargin = args.length (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5382 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5383 + if (nargin < 3 || nargin > 5) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5384 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5385 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5386 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5387 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5388 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5389 + Matrix code = args(0).matrix_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5390 + int nsym = code.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5391 + int nn = code.cols (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5392 + int k = args(1).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5393 + int t = args(2).nint_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5394 + int t2 = t << 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5395 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5396 + int m = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5397 + while (nn > (1<<m)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5398 + m++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5399 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5400 + int n = (1<<m) - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5401 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5402 + if ((n < 3) || (n < k) || (m > __OCTAVE_GALOIS_MAX_M)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5403 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5404 + error ("bchdeco: invalid values of message or codeword length"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5405 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5406 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5407 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5408 + int prim = 0; // primitve polynomial of zero flags default |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5409 + bool parity_at_end = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5410 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5411 + for (int i = 3; i < nargin; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5412 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5413 + if (args(i).is_string ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5414 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5415 + std::string parstr = args(i).string_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5416 + for (int j = 0; j < (int)parstr.length (); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5417 + parstr[j] = toupper (parstr[j]); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5418 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5419 + if (!parstr.compare("END")) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5420 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5421 + parity_at_end = true; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5422 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5423 + else if (!parstr.compare("BEGINNING")) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5424 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5425 + parity_at_end = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5426 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5427 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5428 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5429 + error ("bchdeco: unrecoginized parity position"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5430 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5431 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5432 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5433 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5434 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5435 + if (args(i).is_real_scalar ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5436 + prim = args(i).int_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5437 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5438 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5439 + Matrix tmp = args(i).matrix_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5440 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5441 + if (tmp.cols () > tmp.rows ()) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5442 + tmp = tmp.transpose (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5443 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5444 + if (tmp.cols () != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5445 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5446 + error ("bchdeco: the primitve polynomial must be a scalar " |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5447 + "or a vector"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5448 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5449 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5450 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5451 + prim = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5452 + for (int i = 0; i < tmp.rows (); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5453 + if ((int)tmp(i, 0) & 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5454 + prim |= (1<<i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5455 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5456 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5457 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5458 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5459 + // Create a variable in the require Galois Field to have access to the |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5460 + // lookup tables alpha_to and index_of. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5461 + galois tables (1, 1, 0, m, prim); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5462 + ColumnVector nerr (nsym, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5463 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5464 + for (int lsym = 0; lsym < nsym; lsym++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5465 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5466 + /* first form the syndromes */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5467 + Array<int> s (dim_vector(t2+1, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5468 + bool syn_error = false; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5469 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5470 + for (int i = 1; i <= t2; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5471 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5472 + for (int j = 0; j < nn; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5473 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5474 + if (parity_at_end) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5475 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5476 + if (code(lsym, nn-j-1) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5477 + s(i) ^= tables.alpha_to (modn (i*j, m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5478 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5479 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5480 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5481 + if (code(lsym, j) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5482 + s(i) ^= tables.alpha_to (modn (i*j, m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5483 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5484 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5485 + if (s(i) != 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5486 + syn_error = true; /* set error flag if non-zero syndrome */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5487 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5488 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5489 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5490 + if (syn_error) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5491 + { /* if there are errors, try to correct them */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5492 + int q, u; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5493 + Array<int> d (dim_vector (t2+2, 1)), l(dim_vector (t2+2, 1)), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5494 + u_lu(dim_vector (t2+2, 1)), reg(dim_vector (t2+2, 1)), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5495 + elp(dim_vector (t2+2, t2+2)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5496 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5497 + /* convert syndrome from polynomial form to index form */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5498 + for (int i = 1; i <= t2; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5499 + s(i) = tables.index_of (s(i)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5500 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5501 + /* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5502 + * Compute the error location polynomial via the Berlekamp |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5503 + * iterative algorithm. Following the terminology of Lin and |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5504 + * Costello's book : d(u) is the 'mu'th discrepancy, where |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5505 + * u='mu'+1 and 'mu' (the Greek letter!) is the step number |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5506 + * ranging from -1 to 2*t (see L&C), l(u) is the degree of |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5507 + * the elp at that step, and u_l(u) is the difference between |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5508 + * the step number and the degree of the elp. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5509 + */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5510 + /* initialise table entries */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5511 + d(0) = 0; /* index form */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5512 + d(1) = s(1); /* index form */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5513 + elp(0, 0) = 0; /* index form */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5514 + elp(1, 0) = 1; /* polynomial form */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5515 + for (int i = 1; i < t2; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5516 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5517 + elp(0, i) = n; /* index form */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5518 + elp(1, i) = 0; /* polynomial form */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5519 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5520 + l(0) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5521 + l(1) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5522 + u_lu(0) = -1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5523 + u_lu(1) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5524 + u = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5525 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5526 + do |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5527 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5528 + u++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5529 + if (d(u) == n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5530 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5531 + l(u + 1) = l(u); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5532 + for (int i = 0; i <= l(u); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5533 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5534 + elp(u + 1, i) = elp(u, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5535 + elp(u, i) = tables.index_of (elp(u, i)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5536 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5537 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5538 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5539 + /* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5540 + * search for words with greatest u_lu(q) for |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5541 + * which d(q)!=0 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5542 + */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5543 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5544 + q = u - 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5545 + while ((d(q) == n) && (q > 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5546 + q--; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5547 + /* have found first non-zero d(q) */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5548 + if (q > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5549 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5550 + int j = q; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5551 + do |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5552 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5553 + j--; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5554 + if ((d(j) != n) && (u_lu(q) < u_lu(j))) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5555 + q = j; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5556 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5557 + while (j > 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5558 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5559 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5560 + /* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5561 + * have now found q such that d(u)!=0 and |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5562 + * u_lu(q) is maximum |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5563 + */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5564 + /* store degree of new elp polynomial */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5565 + if (l(u) > l(q) + u - q) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5566 + l(u + 1) = l(u); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5567 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5568 + l(u + 1) = l(q) + u - q; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5569 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5570 + /* form new elp(x) */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5571 + for (int i = 0; i < t2; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5572 + elp(u + 1, i) = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5573 + for (int i = 0; i <= l(q); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5574 + if (elp(q, i) != n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5575 + elp(u + 1, i + u - q) = |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5576 + tables.alpha_to (modn ((d(u) + n - d(q) + elp(q, i)), m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5577 + for (int i = 0; i <= l(u); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5578 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5579 + elp(u + 1, i) ^= elp(u, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5580 + elp(u, i) = tables.index_of (elp(u, i)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5581 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5582 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5583 + u_lu(u + 1) = u - l(u + 1); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5584 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5585 + /* form (u+1)th discrepancy */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5586 + if (u < t2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5587 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5588 + /* no discrepancy computed on last iteration */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5589 + d(u + 1) = tables.alpha_to (s(u + 1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5590 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5591 + for (int i = 1; i <= l(u + 1); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5592 + if ((s(u + 1 - i) != n) && (elp(u + 1, i) != 0)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5593 + d(u + 1) ^= tables.alpha_to (modn (s(u + 1 - i) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5594 + + tables.index_of (elp(u + 1, i)), |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5595 + m, n)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5596 + /* put d(u+1) into index form */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5597 + d(u + 1) = tables.index_of (d(u + 1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5598 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5599 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5600 + while ((u < t2) && (l(u + 1) <= t)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5601 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5602 + u++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5603 + if (l(u) <= t) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5604 + {/* Can correct errors */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5605 + int count; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5606 + Array<int> loc (dim_vector (t+2, 1)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5607 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5608 + /* put elp into index form */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5609 + for (int i = 0; i <= l(u); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5610 + elp(u, i) = tables.index_of (elp(u, i)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5611 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5612 + /* Chien search: find roots of the error location polynomial */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5613 + for (int i = 1; i <= l(u); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5614 + reg(i) = elp(u, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5615 + count = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5616 + for (int i = 1; i <= n; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5617 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5618 + q = 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5619 + for (int j = 1; j <= l(u); j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5620 + if (reg(j) != n) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5621 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5622 + reg(j) = modn ((reg(j) + j), m, n); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5623 + q ^= tables.alpha_to (reg(j)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5624 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5625 + if (!q) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5626 + { /* store root and error |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5627 + * location number indices */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5628 + loc(count) = n - i; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5629 + count++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5630 + if (count > l(u)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5631 + break; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5632 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5633 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5634 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5635 + if (count == l(u)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5636 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5637 + /* no. roots = degree of elp hence <= t errors */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5638 + nerr(lsym) = l(u); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5639 + for (int i = 0; i < l(u); i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5640 + if (parity_at_end) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5641 + code(lsym, nn-loc(i)-1) = |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5642 + (int)code(lsym, nn-loc(i)-1) ^ 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5643 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5644 + code(lsym, loc(i)) = (int)code(lsym, loc(i)) ^ 1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5645 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5646 + else /* elp has degree >t hence cannot solve */ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5647 + nerr(lsym) = -1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5648 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5649 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5650 + nerr(lsym) = -1; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5651 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5652 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5653 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5654 + Matrix msg (nsym, k); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5655 + if (parity_at_end) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5656 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5657 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5658 + for (int i = 0; i < k; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5659 + msg(l, i) = code(l, i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5660 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5661 + else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5662 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5663 + for (int l = 0; l < nsym; l++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5664 + for (int i = 0; i < k; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5665 + msg(l, i) = code(l, nn-k+i); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5666 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5667 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5668 + retval(0) = octave_value (msg); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5669 + retval(1) = octave_value (nerr); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5670 + retval(2) = octave_value (code); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5671 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5672 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5673 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5674 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5675 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5676 +%!error bchdeco () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5677 +%!error bchdeco (1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5678 +%!error bchdeco (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5679 +%!error bchdeco (1, 2, 3, 4, 5, 6) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5680 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5681 diff -uNr a/src/__gfweight__.cc b/src/__gfweight__.cc |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5682 --- a/src/__gfweight__.cc 2015-04-04 12:28:43.938510295 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5683 +++ b/src/__gfweight__.cc 2018-04-09 13:51:01.973935827 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5684 @@ -68,7 +68,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5685 if (k > 128) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5686 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5687 octave_stdout << "__gfweight__: this is likely to take a very long time!!\n"; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5688 - flush_octave_stdout (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5689 + octave::flush_stdout (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5690 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5691 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5692 Array<char> codeword (dim_vector (n, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5693 diff -uNr a/src/__gfweight__.cc~ b/src/__gfweight__.cc~ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5694 --- a/src/__gfweight__.cc~ 1969-12-31 19:00:00.000000000 -0500 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5695 +++ b/src/__gfweight__.cc~ 2015-04-04 12:28:43.938510295 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5696 @@ -0,0 +1,89 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5697 +//Copyright (C) 2003 David Bateman |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5698 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5699 +// This program is free software; you can redistribute it and/or |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5700 +// modify it under the terms of the GNU General Public License as |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5701 +// published by the Free Software Foundation; either version 3 of the |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5702 +// License, or (at your option) any later version. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5703 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5704 +// This program is distributed in the hope that it will be useful, but |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5705 +// WITHOUT ANY WARRANTY; without even the implied warranty of |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5706 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5707 +// General Public License for more details. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5708 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5709 +// You should have received a copy of the GNU General Public License |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5710 +// along with this program; if not, see |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5711 +// <http://www.gnu.org/licenses/>. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5712 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5713 +// In addition to the terms of the GPL, you are permitted to link this |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5714 +// program with any Open Source program, as defined by the Open Source |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5715 +// Initiative (www.opensource.org) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5716 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5717 +#include <octave/oct.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5718 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5719 +static int |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5720 +get_weight (const Array<char>& codeword, const Matrix& gen, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5721 + int weight, int depth, int start, int n, int k) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5722 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5723 + int retval = weight; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5724 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5725 + for (int i = start; i < k ; i++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5726 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5727 + OCTAVE_QUIT; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5728 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5729 + Array<char> new_codeword (codeword); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5730 + int tmp = 0; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5731 + for (int j = 0; j < n; j++) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5732 + if (new_codeword (j) ^= (char)gen(i,j)) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5733 + tmp++; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5734 + if (tmp < retval) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5735 + retval = tmp; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5736 + if (depth < retval) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5737 + retval = get_weight (new_codeword, gen, retval, depth+1, i+1, n, k); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5738 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5739 + return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5740 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5741 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5742 +DEFUN_DLD (__gfweight__, args, , |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5743 + "-*- texinfo -*-\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5744 +@deftypefn {Loadable Function} {@var{w} =} __gfweight__ (@var{gen})\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5745 +Returns the minimum distance @var{w} of the generator matrix @var{gen}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5746 +The codeword length is @var{k}.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5747 +\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5748 +This is an internal function of @code{gfweight}. You should use\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5749 +@code{gfweight} rather than use this function directly.\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5750 +@seealso{gfweight}\n\ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5751 +@end deftypefn") |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5752 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5753 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5754 + if (args.length () != 1) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5755 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5756 + print_usage (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5757 + return octave_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5758 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5759 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5760 + Matrix gen = args(0).matrix_value (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5761 + int k = gen.rows (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5762 + int n = gen.columns (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5763 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5764 + if (k > 128) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5765 + { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5766 + octave_stdout << "__gfweight__: this is likely to take a very long time!!\n"; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5767 + flush_octave_stdout (); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5768 + } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5769 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5770 + Array<char> codeword (dim_vector (n, 1), 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5771 + return octave_value ((double)get_weight (codeword, gen, n - k + 1, 1, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5772 + 0, n, k)); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5773 +} |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5774 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5775 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5776 +%% Test input validation |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5777 +%!error __gfweight__ () |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5778 +%!error __gfweight__ (1, 2) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5779 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5780 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5781 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5782 +;;; Local Variables: *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5783 +;;; mode: C++ *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5784 +;;; End: *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5785 +*/ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5786 diff -uNr a/src/ov-galois.cc b/src/ov-galois.cc |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5787 --- a/src/ov-galois.cc 2018-04-09 13:25:42.884981069 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5788 +++ b/src/ov-galois.cc 2018-04-09 13:27:40.103502409 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5789 @@ -21,7 +21,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5790 #include <iostream> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5791 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5792 #include <octave/byte-swap.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5793 -#include <octave/gripes.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5794 +#include <octave/errwarn.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5795 #include <octave/lo-ieee.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5796 #include <octave/oct-locbuf.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5797 #include <octave/oct-obj.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5798 @@ -328,13 +328,13 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5799 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5800 if (rows () > 0 && columns () > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5801 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5802 - gripe_implicit_conversion ("Octave:array-as-scalar", |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5803 + warn_implicit_conversion ("Octave:array-as-scalar", |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5804 "real matrix", "real scalar"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5805 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5806 retval = (double) gval (0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5807 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5808 else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5809 - gripe_invalid_conversion ("galois", "real scalar"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5810 + err_invalid_conversion ("galois", "real scalar"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5811 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5812 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5813 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5814 @@ -348,13 +348,13 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5815 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5816 if (rows () > 0 && columns () > 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5817 { |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5818 - gripe_implicit_conversion ("Octave:array-as-scalar", |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5819 + warn_implicit_conversion ("Octave:array-as-scalar", |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5820 "real matrix", "real scalar"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5821 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5822 retval = (double) gval (0, 0); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5823 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5824 else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5825 - gripe_invalid_conversion ("galois", "complex scalar"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5826 + err_invalid_conversion ("galois", "complex scalar"); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5827 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5828 return retval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5829 } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5830 diff -uNr a/src/ov-galois.h b/src/ov-galois.h |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5831 --- a/src/ov-galois.h 2018-04-09 13:25:42.872981630 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5832 +++ b/src/ov-galois.h 2018-04-09 14:09:33.961913785 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5833 @@ -49,7 +49,6 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5834 #endif |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5835 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5836 class octave_value_list; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5837 -class tree_walker; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5838 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5839 // Data structures. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5840 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5841 @@ -100,7 +99,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5842 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5843 bool is_defined (void) const { return true; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5844 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5845 - bool is_numeric_type (void) const { return true; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5846 + bool isnumeric (void) const { return true; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5847 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5848 bool is_constant (void) const { return true; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5849 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5850 @@ -124,7 +123,7 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5851 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5852 bool is_real_matrix (void) const { return false; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5853 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5854 - bool is_real_type (void) const { return false; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5855 + bool isreal (void) const { return false; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5856 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5857 // FIXME |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5858 bool valid_as_scalar_index (void) const { return false; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5859 diff -uNr a/src/ov-galois.h~ b/src/ov-galois.h~ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5860 --- a/src/ov-galois.h~ 1969-12-31 19:00:00.000000000 -0500 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5861 +++ b/src/ov-galois.h~ 2018-04-09 13:35:21.137945379 -0400 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5862 @@ -0,0 +1,183 @@ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5863 +//Copyright (C) 2003 David Bateman |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5864 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5865 +// This program is free software; you can redistribute it and/or |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5866 +// modify it under the terms of the GNU General Public License as |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5867 +// published by the Free Software Foundation; either version 3 of the |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5868 +// License, or (at your option) any later version. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5869 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5870 +// This program is distributed in the hope that it will be useful, but |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5871 +// WITHOUT ANY WARRANTY; without even the implied warranty of |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5872 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5873 +// General Public License for more details. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5874 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5875 +// You should have received a copy of the GNU General Public License |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5876 +// along with this program; if not, see |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5877 +// <http://www.gnu.org/licenses/>. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5878 +// |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5879 +// In addition to the terms of the GPL, you are permitted to link this |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5880 +// program with any Open Source program, as defined by the Open Source |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5881 +// Initiative (www.opensource.org) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5882 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5883 +#if !defined (octave_galois_h) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5884 +#define octave_galois_h 1 |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5885 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5886 +#include <octave/ov.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5887 +#include <octave/ov-typeinfo.h> |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5888 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5889 +#include "galois.h" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5890 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5891 +// The keys of the values in the octave map |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5892 +#define __GALOIS_PRIMPOLY_STR "prim_poly" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5893 +#define __GALOIS_ORDER_STR "m" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5894 +#define __GALOIS_DATA_STR "x" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5895 +#ifdef GALOIS_DISP_PRIVATES |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5896 +#define __GALOIS_LENGTH_STR "n" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5897 +#define __GALOIS_ALPHA_TO_STR "alpha_to" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5898 +#define __GALOIS_INDEX_OF_STR "index_of" |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5899 +#endif |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5900 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5901 +#if !defined (HAVE_OCTAVE_HDF5_ID_TYPE) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5902 +#if defined (HAVE_HDF5) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5903 +typedef hid_t octave_hdf5_id; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5904 +#else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5905 +typedef int octave_hdf5_id; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5906 +#endif |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5907 +#endif |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5908 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5909 +#if ! defined (OV_REP_TYPE) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5910 +# define OV_REP_TYPE octave_base_value |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5911 +#endif |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5912 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5913 +class octave_value_list; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5914 +class tree_walker; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5915 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5916 +// Data structures. |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5917 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5918 +class |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5919 +octave_galois : public octave_base_value |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5920 +{ |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5921 +public: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5922 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5923 + octave_galois (const Matrix& data = Matrix (0, 0), const int _m = 1, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5924 + const int _primpoly = 0) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5925 + { gval = galois (data, _m, _primpoly); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5926 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5927 + octave_galois (const galois& gm) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5928 + : octave_base_value (), gval (gm) { } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5929 + octave_galois (const octave_galois& s) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5930 + : octave_base_value (), gval (s.gval) { } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5931 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5932 + ~octave_galois (void) { }; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5933 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5934 + OV_REP_TYPE *clone (void) const { return new octave_galois (*this); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5935 + OV_REP_TYPE *empty_clone (void) const { return new octave_galois (); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5936 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5937 + octave_value subsref (const std::string &type, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5938 + const std::list<octave_value_list>& idx); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5939 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5940 + octave_value_list subsref (const std::string& type, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5941 + const std::list<octave_value_list>& idx, int) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5942 + { return subsref (type, idx); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5943 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5944 + octave_value do_index_op (const octave_value_list& idx, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5945 + bool resize_ok); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5946 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5947 + octave_value do_index_op (const octave_value_list& idx) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5948 + { return do_index_op (idx, 0); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5949 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5950 + void assign (const octave_value_list& idx, const galois& rhs); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5951 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5952 + dim_vector dims (void) const { return gval.dims (); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5953 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5954 + octave_value resize (const dim_vector& dv, bool) const; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5955 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5956 + size_t byte_size (void) const { return gval.byte_size (); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5957 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5958 + octave_value all (int dim = 0) const { return gval.all (dim); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5959 + octave_value any (int dim = 0) const { return gval.any (dim); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5960 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5961 + bool is_matrix_type (void) const { return true; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5962 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5963 + bool is_defined (void) const { return true; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5964 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5965 + bool isnumeric (void) const { return true; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5966 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5967 + bool is_constant (void) const { return true; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5968 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5969 + bool is_true (void) const; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5970 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5971 + bool is_galois_type (void) const { return true; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5972 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5973 + bool print_as_scalar (void) const; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5974 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5975 +#if defined (HAVE_OCTAVE_BASE_VALUE_PRINT_CONST) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5976 + void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5977 +#else |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5978 + void print (std::ostream& os, bool pr_as_read_syntax = false); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5979 +#endif |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5980 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5981 + void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5982 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5983 + bool print_name_tag (std::ostream& os, const std::string& name) const; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5984 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5985 + void print_info (std::ostream& os, const std::string& prefix) const; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5986 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5987 + bool is_real_matrix (void) const { return false; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5988 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5989 + bool isreal (void) const { return false; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5990 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5991 + // FIXME |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5992 + bool valid_as_scalar_index (void) const { return false; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5993 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5994 + double double_value (bool = false) const; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5995 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5996 + double scalar_value (bool frc_str_conv = false) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5997 + { return double_value (frc_str_conv); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5998 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5999 + Matrix matrix_value (bool = false) const; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6000 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6001 + NDArray array_value (bool = false) const; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6002 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6003 + Complex complex_value (bool = false) const; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6004 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6005 + ComplexMatrix complex_matrix_value (bool = false) const |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6006 + { return ComplexMatrix ( matrix_value ()); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6007 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6008 + galois galois_value (void) const { return gval; } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6009 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6010 + octave_value_list dotref (const octave_value_list& idx); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6011 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6012 + int m (void) const { return gval.m (); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6013 + int primpoly (void) const { return gval.primpoly (); } |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6014 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6015 + bool save_ascii (std::ostream& os); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6016 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6017 + bool load_ascii (std::istream& is); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6018 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6019 + bool save_binary (std::ostream& os, bool& save_as_floats); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6020 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6021 + bool load_binary (std::istream& is, bool swap, |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6022 + oct_mach_info::float_format fmt); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6023 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6024 + bool save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6025 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6026 + bool load_hdf5 (octave_hdf5_id loc_id, const char *name); |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6027 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6028 +private: |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6029 + // The array used to managed the Galios Field data |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6030 + galois gval; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6031 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6032 +#if defined (DECLARE_OCTAVE_ALLOCATOR) |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6033 + DECLARE_OCTAVE_ALLOCATOR |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6034 +#endif |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6035 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6036 + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6037 +}; |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6038 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6039 +#endif |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6040 + |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6041 +/* |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6042 +;;; Local Variables: *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6043 +;;; mode: C++ *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6044 +;;; End: *** |
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6045 +*/ |