Mercurial > hg > octave-lyh
comparison liboctave/PermMatrix.cc @ 11570:57632dea2446
attempt better backward compatibility for Array constructors
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 19 Jan 2011 17:55:56 -0500 |
parents | fd0a3ac60b0e |
children | 12df7854fa7c |
comparison
equal
deleted
inserted
replaced
11569:7e9a111cae20 | 11570:57632dea2446 |
---|---|
55 octave_idx_type len = idx.length (n); | 55 octave_idx_type len = idx.length (n); |
56 if (! idx.is_permutation (len)) | 56 if (! idx.is_permutation (len)) |
57 gripe_invalid_permutation (); | 57 gripe_invalid_permutation (); |
58 else | 58 else |
59 { | 59 { |
60 Array<octave_idx_type> idxa (len, 1); | 60 Array<octave_idx_type> idxa (dim_vector (len, 1)); |
61 for (octave_idx_type i = 0; i < len; i++) idxa(i) = idx(i); | 61 for (octave_idx_type i = 0; i < len; i++) idxa(i) = idx(i); |
62 Array<octave_idx_type>::operator = (idxa); | 62 Array<octave_idx_type>::operator = (idxa); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 PermMatrix::PermMatrix (octave_idx_type n) | 66 PermMatrix::PermMatrix (octave_idx_type n) |
67 : Array<octave_idx_type> (n, 1), _colp (false) | 67 : Array<octave_idx_type> (dim_vector (n, 1)), _colp (false) |
68 { | 68 { |
69 for (octave_idx_type i = 0; i < n; i++) xelem (i) = i; | 69 for (octave_idx_type i = 0; i < n; i++) xelem (i) = i; |
70 } | 70 } |
71 | 71 |
72 octave_idx_type | 72 octave_idx_type |
143 } | 143 } |
144 else if (m == 0) | 144 else if (m == 0) |
145 return PermMatrix (n); | 145 return PermMatrix (n); |
146 | 146 |
147 const octave_idx_type *p = data (); | 147 const octave_idx_type *p = data (); |
148 Array<octave_idx_type> res_pvec (n, 1, -1); | 148 Array<octave_idx_type> res_pvec (dim_vector (n, 1), -1); |
149 octave_idx_type *q = res_pvec.fortran_vec (); | 149 octave_idx_type *q = res_pvec.fortran_vec (); |
150 | 150 |
151 for (octave_idx_type ics = 0; ics < n; ics++) | 151 for (octave_idx_type ics = 0; ics < n; ics++) |
152 { | 152 { |
153 if (q[ics] > 0) | 153 if (q[ics] > 0) |
179 } | 179 } |
180 | 180 |
181 PermMatrix | 181 PermMatrix |
182 PermMatrix::eye (octave_idx_type n) | 182 PermMatrix::eye (octave_idx_type n) |
183 { | 183 { |
184 Array<octave_idx_type> p(n, 1); | 184 Array<octave_idx_type> p (dim_vector (n, 1)); |
185 for (octave_idx_type i = 0; i < n; i++) | 185 for (octave_idx_type i = 0; i < n; i++) |
186 p(i) = i; | 186 p(i) = i; |
187 | 187 |
188 return PermMatrix (p, false, false); | 188 return PermMatrix (p, false, false); |
189 } | 189 } |
202 ? ia.index (idx_vector (ib)) | 202 ? ia.index (idx_vector (ib)) |
203 : ib.index (idx_vector (ia))), a._colp, false); | 203 : ib.index (idx_vector (ia))), a._colp, false); |
204 } | 204 } |
205 else | 205 else |
206 { | 206 { |
207 Array<octave_idx_type> ra (n, 1); | 207 Array<octave_idx_type> ra (dim_vector (n, 1)); |
208 if (a._colp) | 208 if (a._colp) |
209 ra.assign (idx_vector (ib), ia); | 209 ra.assign (idx_vector (ib), ia); |
210 else | 210 else |
211 ra.assign (idx_vector (ia), ib); | 211 ra.assign (idx_vector (ia), ib); |
212 r = PermMatrix (ra, a._colp, false); | 212 r = PermMatrix (ra, a._colp, false); |