Mercurial > hg > octave-lyh
comparison liboctave/CMatrix.cc @ 5275:23b37da9fd5b
[project @ 2005-04-08 16:07:35 by jwe]
author | jwe |
---|---|
date | Fri, 08 Apr 2005 16:07:37 +0000 |
parents | deed800e7bef |
children | 4c8a2e4e0717 |
comparison
equal
deleted
inserted
replaced
5274:eae7b40388e9 | 5275:23b37da9fd5b |
---|---|
62 | 62 |
63 extern "C" | 63 extern "C" |
64 { | 64 { |
65 F77_RET_T | 65 F77_RET_T |
66 F77_FUNC (zgebal, ZGEBAL) (F77_CONST_CHAR_ARG_DECL, | 66 F77_FUNC (zgebal, ZGEBAL) (F77_CONST_CHAR_ARG_DECL, |
67 const int&, Complex*, const int&, int&, | 67 const octave_idx_type&, Complex*, const octave_idx_type&, octave_idx_type&, |
68 int&, double*, int& | 68 octave_idx_type&, double*, octave_idx_type& |
69 F77_CHAR_ARG_LEN_DECL); | 69 F77_CHAR_ARG_LEN_DECL); |
70 | 70 |
71 F77_RET_T | 71 F77_RET_T |
72 F77_FUNC (dgebak, DGEBAK) (F77_CONST_CHAR_ARG_DECL, | 72 F77_FUNC (dgebak, DGEBAK) (F77_CONST_CHAR_ARG_DECL, |
73 F77_CONST_CHAR_ARG_DECL, | 73 F77_CONST_CHAR_ARG_DECL, |
74 const int&, const int&, const int&, double*, | 74 const octave_idx_type&, const octave_idx_type&, const octave_idx_type&, double*, |
75 const int&, double*, const int&, int& | 75 const octave_idx_type&, double*, const octave_idx_type&, octave_idx_type& |
76 F77_CHAR_ARG_LEN_DECL | 76 F77_CHAR_ARG_LEN_DECL |
77 F77_CHAR_ARG_LEN_DECL); | 77 F77_CHAR_ARG_LEN_DECL); |
78 | 78 |
79 F77_RET_T | 79 F77_RET_T |
80 F77_FUNC (zgemm, ZGEMM) (F77_CONST_CHAR_ARG_DECL, | 80 F77_FUNC (zgemm, ZGEMM) (F77_CONST_CHAR_ARG_DECL, |
81 F77_CONST_CHAR_ARG_DECL, | 81 F77_CONST_CHAR_ARG_DECL, |
82 const int&, const int&, const int&, | 82 const octave_idx_type&, const octave_idx_type&, const octave_idx_type&, |
83 const Complex&, const Complex*, const int&, | 83 const Complex&, const Complex*, const octave_idx_type&, |
84 const Complex*, const int&, const Complex&, | 84 const Complex*, const octave_idx_type&, const Complex&, |
85 Complex*, const int& | 85 Complex*, const octave_idx_type& |
86 F77_CHAR_ARG_LEN_DECL | 86 F77_CHAR_ARG_LEN_DECL |
87 F77_CHAR_ARG_LEN_DECL); | 87 F77_CHAR_ARG_LEN_DECL); |
88 | 88 |
89 F77_RET_T | 89 F77_RET_T |
90 F77_FUNC (zgetrf, ZGETRF) (const int&, const int&, Complex*, const int&, | 90 F77_FUNC (zgetrf, ZGETRF) (const octave_idx_type&, const octave_idx_type&, Complex*, const octave_idx_type&, |
91 int*, int&); | 91 octave_idx_type*, octave_idx_type&); |
92 | 92 |
93 F77_RET_T | 93 F77_RET_T |
94 F77_FUNC (zgetrs, ZGETRS) (F77_CONST_CHAR_ARG_DECL, | 94 F77_FUNC (zgetrs, ZGETRS) (F77_CONST_CHAR_ARG_DECL, |
95 const int&, const int&, Complex*, const int&, | 95 const octave_idx_type&, const octave_idx_type&, Complex*, const octave_idx_type&, |
96 const int*, Complex*, const int&, int& | 96 const octave_idx_type*, Complex*, const octave_idx_type&, octave_idx_type& |
97 F77_CHAR_ARG_LEN_DECL); | 97 F77_CHAR_ARG_LEN_DECL); |
98 | 98 |
99 F77_RET_T | 99 F77_RET_T |
100 F77_FUNC (zgetri, ZGETRI) (const int&, Complex*, const int&, const int*, | 100 F77_FUNC (zgetri, ZGETRI) (const octave_idx_type&, Complex*, const octave_idx_type&, const octave_idx_type*, |
101 Complex*, const int&, int&); | 101 Complex*, const octave_idx_type&, octave_idx_type&); |
102 | 102 |
103 F77_RET_T | 103 F77_RET_T |
104 F77_FUNC (zgecon, ZGECON) (F77_CONST_CHAR_ARG_DECL, | 104 F77_FUNC (zgecon, ZGECON) (F77_CONST_CHAR_ARG_DECL, |
105 const int&, Complex*, | 105 const octave_idx_type&, Complex*, |
106 const int&, const double&, double&, | 106 const octave_idx_type&, const double&, double&, |
107 Complex*, double*, int& | 107 Complex*, double*, octave_idx_type& |
108 F77_CHAR_ARG_LEN_DECL); | 108 F77_CHAR_ARG_LEN_DECL); |
109 | 109 |
110 F77_RET_T | 110 F77_RET_T |
111 F77_FUNC (zgelss, ZGELSS) (const int&, const int&, const int&, | 111 F77_FUNC (zgelss, ZGELSS) (const octave_idx_type&, const octave_idx_type&, const octave_idx_type&, |
112 Complex*, const int&, Complex*, | 112 Complex*, const octave_idx_type&, Complex*, |
113 const int&, double*, double&, int&, | 113 const octave_idx_type&, double*, double&, octave_idx_type&, |
114 Complex*, const int&, double*, int&); | 114 Complex*, const octave_idx_type&, double*, octave_idx_type&); |
115 | 115 |
116 // Note that the original complex fft routines were not written for | 116 // Note that the original complex fft routines were not written for |
117 // double complex arguments. They have been modified by adding an | 117 // double complex arguments. They have been modified by adding an |
118 // implicit double precision (a-h,o-z) statement at the beginning of | 118 // implicit double precision (a-h,o-z) statement at the beginning of |
119 // each subroutine. | 119 // each subroutine. |
120 | 120 |
121 F77_RET_T | 121 F77_RET_T |
122 F77_FUNC (cffti, CFFTI) (const int&, Complex*); | 122 F77_FUNC (cffti, CFFTI) (const octave_idx_type&, Complex*); |
123 | 123 |
124 F77_RET_T | 124 F77_RET_T |
125 F77_FUNC (cfftf, CFFTF) (const int&, Complex*, Complex*); | 125 F77_FUNC (cfftf, CFFTF) (const octave_idx_type&, Complex*, Complex*); |
126 | 126 |
127 F77_RET_T | 127 F77_RET_T |
128 F77_FUNC (cfftb, CFFTB) (const int&, Complex*, Complex*); | 128 F77_FUNC (cfftb, CFFTB) (const octave_idx_type&, Complex*, Complex*); |
129 | 129 |
130 F77_RET_T | 130 F77_RET_T |
131 F77_FUNC (zlartg, ZLARTG) (const Complex&, const Complex&, | 131 F77_FUNC (zlartg, ZLARTG) (const Complex&, const Complex&, |
132 double&, Complex&, Complex&); | 132 double&, Complex&, Complex&); |
133 | 133 |
134 F77_RET_T | 134 F77_RET_T |
135 F77_FUNC (ztrsyl, ZTRSYL) (F77_CONST_CHAR_ARG_DECL, | 135 F77_FUNC (ztrsyl, ZTRSYL) (F77_CONST_CHAR_ARG_DECL, |
136 F77_CONST_CHAR_ARG_DECL, | 136 F77_CONST_CHAR_ARG_DECL, |
137 const int&, const int&, const int&, | 137 const octave_idx_type&, const octave_idx_type&, const octave_idx_type&, |
138 const Complex*, const int&, | 138 const Complex*, const octave_idx_type&, |
139 const Complex*, const int&, | 139 const Complex*, const octave_idx_type&, |
140 const Complex*, const int&, double&, int& | 140 const Complex*, const octave_idx_type&, double&, octave_idx_type& |
141 F77_CHAR_ARG_LEN_DECL | 141 F77_CHAR_ARG_LEN_DECL |
142 F77_CHAR_ARG_LEN_DECL); | 142 F77_CHAR_ARG_LEN_DECL); |
143 | 143 |
144 F77_RET_T | 144 F77_RET_T |
145 F77_FUNC (xzlange, XZLANGE) (F77_CONST_CHAR_ARG_DECL, | 145 F77_FUNC (xzlange, XZLANGE) (F77_CONST_CHAR_ARG_DECL, |
146 const int&, const int&, const Complex*, | 146 const octave_idx_type&, const octave_idx_type&, const Complex*, |
147 const int&, double*, double& | 147 const octave_idx_type&, double*, double& |
148 F77_CHAR_ARG_LEN_DECL); | 148 F77_CHAR_ARG_LEN_DECL); |
149 } | 149 } |
150 | 150 |
151 static const Complex Complex_NaN_result (octave_NaN, octave_NaN); | 151 static const Complex Complex_NaN_result (octave_NaN, octave_NaN); |
152 | 152 |
153 // Complex Matrix class | 153 // Complex Matrix class |
154 | 154 |
155 ComplexMatrix::ComplexMatrix (const Matrix& a) | 155 ComplexMatrix::ComplexMatrix (const Matrix& a) |
156 : MArray2<Complex> (a.rows (), a.cols ()) | 156 : MArray2<Complex> (a.rows (), a.cols ()) |
157 { | 157 { |
158 for (int j = 0; j < cols (); j++) | 158 for (octave_idx_type j = 0; j < cols (); j++) |
159 for (int i = 0; i < rows (); i++) | 159 for (octave_idx_type i = 0; i < rows (); i++) |
160 elem (i, j) = a.elem (i, j); | 160 elem (i, j) = a.elem (i, j); |
161 } | 161 } |
162 | 162 |
163 ComplexMatrix::ComplexMatrix (const RowVector& rv) | 163 ComplexMatrix::ComplexMatrix (const RowVector& rv) |
164 : MArray2<Complex> (1, rv.length (), 0.0) | 164 : MArray2<Complex> (1, rv.length (), 0.0) |
165 { | 165 { |
166 for (int i = 0; i < rv.length (); i++) | 166 for (octave_idx_type i = 0; i < rv.length (); i++) |
167 elem (0, i) = rv.elem (i); | 167 elem (0, i) = rv.elem (i); |
168 } | 168 } |
169 | 169 |
170 ComplexMatrix::ComplexMatrix (const ColumnVector& cv) | 170 ComplexMatrix::ComplexMatrix (const ColumnVector& cv) |
171 : MArray2<Complex> (cv.length (), 1, 0.0) | 171 : MArray2<Complex> (cv.length (), 1, 0.0) |
172 { | 172 { |
173 for (int i = 0; i < cv.length (); i++) | 173 for (octave_idx_type i = 0; i < cv.length (); i++) |
174 elem (i, 0) = cv.elem (i); | 174 elem (i, 0) = cv.elem (i); |
175 } | 175 } |
176 | 176 |
177 ComplexMatrix::ComplexMatrix (const DiagMatrix& a) | 177 ComplexMatrix::ComplexMatrix (const DiagMatrix& a) |
178 : MArray2<Complex> (a.rows (), a.cols (), 0.0) | 178 : MArray2<Complex> (a.rows (), a.cols (), 0.0) |
179 { | 179 { |
180 for (int i = 0; i < a.length (); i++) | 180 for (octave_idx_type i = 0; i < a.length (); i++) |
181 elem (i, i) = a.elem (i, i); | 181 elem (i, i) = a.elem (i, i); |
182 } | 182 } |
183 | 183 |
184 ComplexMatrix::ComplexMatrix (const ComplexRowVector& rv) | 184 ComplexMatrix::ComplexMatrix (const ComplexRowVector& rv) |
185 : MArray2<Complex> (1, rv.length (), 0.0) | 185 : MArray2<Complex> (1, rv.length (), 0.0) |
186 { | 186 { |
187 for (int i = 0; i < rv.length (); i++) | 187 for (octave_idx_type i = 0; i < rv.length (); i++) |
188 elem (0, i) = rv.elem (i); | 188 elem (0, i) = rv.elem (i); |
189 } | 189 } |
190 | 190 |
191 ComplexMatrix::ComplexMatrix (const ComplexColumnVector& cv) | 191 ComplexMatrix::ComplexMatrix (const ComplexColumnVector& cv) |
192 : MArray2<Complex> (cv.length (), 1, 0.0) | 192 : MArray2<Complex> (cv.length (), 1, 0.0) |
193 { | 193 { |
194 for (int i = 0; i < cv.length (); i++) | 194 for (octave_idx_type i = 0; i < cv.length (); i++) |
195 elem (i, 0) = cv.elem (i); | 195 elem (i, 0) = cv.elem (i); |
196 } | 196 } |
197 | 197 |
198 ComplexMatrix::ComplexMatrix (const ComplexDiagMatrix& a) | 198 ComplexMatrix::ComplexMatrix (const ComplexDiagMatrix& a) |
199 : MArray2<Complex> (a.rows (), a.cols (), 0.0) | 199 : MArray2<Complex> (a.rows (), a.cols (), 0.0) |
200 { | 200 { |
201 for (int i = 0; i < a.length (); i++) | 201 for (octave_idx_type i = 0; i < a.length (); i++) |
202 elem (i, i) = a.elem (i, i); | 202 elem (i, i) = a.elem (i, i); |
203 } | 203 } |
204 | 204 |
205 // XXX FIXME XXX -- could we use a templated mixed-type copy function | 205 // XXX FIXME XXX -- could we use a templated mixed-type copy function |
206 // here? | 206 // here? |
207 | 207 |
208 ComplexMatrix::ComplexMatrix (const boolMatrix& a) | 208 ComplexMatrix::ComplexMatrix (const boolMatrix& a) |
209 : MArray2<Complex> (a.rows (), a.cols (), 0.0) | 209 : MArray2<Complex> (a.rows (), a.cols (), 0.0) |
210 { | 210 { |
211 for (int i = 0; i < a.rows (); i++) | 211 for (octave_idx_type i = 0; i < a.rows (); i++) |
212 for (int j = 0; j < a.cols (); j++) | 212 for (octave_idx_type j = 0; j < a.cols (); j++) |
213 elem (i, j) = a.elem (i, j); | 213 elem (i, j) = a.elem (i, j); |
214 } | 214 } |
215 | 215 |
216 ComplexMatrix::ComplexMatrix (const charMatrix& a) | 216 ComplexMatrix::ComplexMatrix (const charMatrix& a) |
217 : MArray2<Complex> (a.rows (), a.cols (), 0.0) | 217 : MArray2<Complex> (a.rows (), a.cols (), 0.0) |
218 { | 218 { |
219 for (int i = 0; i < a.rows (); i++) | 219 for (octave_idx_type i = 0; i < a.rows (); i++) |
220 for (int j = 0; j < a.cols (); j++) | 220 for (octave_idx_type j = 0; j < a.cols (); j++) |
221 elem (i, j) = a.elem (i, j); | 221 elem (i, j) = a.elem (i, j); |
222 } | 222 } |
223 | 223 |
224 bool | 224 bool |
225 ComplexMatrix::operator == (const ComplexMatrix& a) const | 225 ComplexMatrix::operator == (const ComplexMatrix& a) const |
237 } | 237 } |
238 | 238 |
239 bool | 239 bool |
240 ComplexMatrix::is_hermitian (void) const | 240 ComplexMatrix::is_hermitian (void) const |
241 { | 241 { |
242 int nr = rows (); | 242 octave_idx_type nr = rows (); |
243 int nc = cols (); | 243 octave_idx_type nc = cols (); |
244 | 244 |
245 if (is_square () && nr > 0) | 245 if (is_square () && nr > 0) |
246 { | 246 { |
247 for (int i = 0; i < nr; i++) | 247 for (octave_idx_type i = 0; i < nr; i++) |
248 for (int j = i; j < nc; j++) | 248 for (octave_idx_type j = i; j < nc; j++) |
249 if (elem (i, j) != conj (elem (j, i))) | 249 if (elem (i, j) != conj (elem (j, i))) |
250 return false; | 250 return false; |
251 | 251 |
252 return true; | 252 return true; |
253 } | 253 } |
256 } | 256 } |
257 | 257 |
258 // destructive insert/delete/reorder operations | 258 // destructive insert/delete/reorder operations |
259 | 259 |
260 ComplexMatrix& | 260 ComplexMatrix& |
261 ComplexMatrix::insert (const Matrix& a, int r, int c) | 261 ComplexMatrix::insert (const Matrix& a, octave_idx_type r, octave_idx_type c) |
262 { | 262 { |
263 int a_nr = a.rows (); | 263 octave_idx_type a_nr = a.rows (); |
264 int a_nc = a.cols (); | 264 octave_idx_type a_nc = a.cols (); |
265 | 265 |
266 if (r < 0 || r + a_nr > rows () || c < 0 || c + a_nc > cols ()) | 266 if (r < 0 || r + a_nr > rows () || c < 0 || c + a_nc > cols ()) |
267 { | 267 { |
268 (*current_liboctave_error_handler) ("range error for insert"); | 268 (*current_liboctave_error_handler) ("range error for insert"); |
269 return *this; | 269 return *this; |
271 | 271 |
272 if (a_nr >0 && a_nc > 0) | 272 if (a_nr >0 && a_nc > 0) |
273 { | 273 { |
274 make_unique (); | 274 make_unique (); |
275 | 275 |
276 for (int j = 0; j < a_nc; j++) | 276 for (octave_idx_type j = 0; j < a_nc; j++) |
277 for (int i = 0; i < a_nr; i++) | 277 for (octave_idx_type i = 0; i < a_nr; i++) |
278 xelem (r+i, c+j) = a.elem (i, j); | 278 xelem (r+i, c+j) = a.elem (i, j); |
279 } | 279 } |
280 | 280 |
281 return *this; | 281 return *this; |
282 } | 282 } |
283 | 283 |
284 ComplexMatrix& | 284 ComplexMatrix& |
285 ComplexMatrix::insert (const RowVector& a, int r, int c) | 285 ComplexMatrix::insert (const RowVector& a, octave_idx_type r, octave_idx_type c) |
286 { | 286 { |
287 int a_len = a.length (); | 287 octave_idx_type a_len = a.length (); |
288 | 288 |
289 if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) | 289 if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) |
290 { | 290 { |
291 (*current_liboctave_error_handler) ("range error for insert"); | 291 (*current_liboctave_error_handler) ("range error for insert"); |
292 return *this; | 292 return *this; |
294 | 294 |
295 if (a_len > 0) | 295 if (a_len > 0) |
296 { | 296 { |
297 make_unique (); | 297 make_unique (); |
298 | 298 |
299 for (int i = 0; i < a_len; i++) | 299 for (octave_idx_type i = 0; i < a_len; i++) |
300 xelem (r, c+i) = a.elem (i); | 300 xelem (r, c+i) = a.elem (i); |
301 } | 301 } |
302 | 302 |
303 return *this; | 303 return *this; |
304 } | 304 } |
305 | 305 |
306 ComplexMatrix& | 306 ComplexMatrix& |
307 ComplexMatrix::insert (const ColumnVector& a, int r, int c) | 307 ComplexMatrix::insert (const ColumnVector& a, octave_idx_type r, octave_idx_type c) |
308 { | 308 { |
309 int a_len = a.length (); | 309 octave_idx_type a_len = a.length (); |
310 | 310 |
311 if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) | 311 if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) |
312 { | 312 { |
313 (*current_liboctave_error_handler) ("range error for insert"); | 313 (*current_liboctave_error_handler) ("range error for insert"); |
314 return *this; | 314 return *this; |
316 | 316 |
317 if (a_len > 0) | 317 if (a_len > 0) |
318 { | 318 { |
319 make_unique (); | 319 make_unique (); |
320 | 320 |
321 for (int i = 0; i < a_len; i++) | 321 for (octave_idx_type i = 0; i < a_len; i++) |
322 xelem (r+i, c) = a.elem (i); | 322 xelem (r+i, c) = a.elem (i); |
323 } | 323 } |
324 | 324 |
325 return *this; | 325 return *this; |
326 } | 326 } |
327 | 327 |
328 ComplexMatrix& | 328 ComplexMatrix& |
329 ComplexMatrix::insert (const DiagMatrix& a, int r, int c) | 329 ComplexMatrix::insert (const DiagMatrix& a, octave_idx_type r, octave_idx_type c) |
330 { | 330 { |
331 int a_nr = a.rows (); | 331 octave_idx_type a_nr = a.rows (); |
332 int a_nc = a.cols (); | 332 octave_idx_type a_nc = a.cols (); |
333 | 333 |
334 if (r < 0 || r + a_nr > rows () || c < 0 || c + a_nc > cols ()) | 334 if (r < 0 || r + a_nr > rows () || c < 0 || c + a_nc > cols ()) |
335 { | 335 { |
336 (*current_liboctave_error_handler) ("range error for insert"); | 336 (*current_liboctave_error_handler) ("range error for insert"); |
337 return *this; | 337 return *this; |
338 } | 338 } |
339 | 339 |
340 fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1); | 340 fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1); |
341 | 341 |
342 int a_len = a.length (); | 342 octave_idx_type a_len = a.length (); |
343 | 343 |
344 if (a_len > 0) | 344 if (a_len > 0) |
345 { | 345 { |
346 make_unique (); | 346 make_unique (); |
347 | 347 |
348 for (int i = 0; i < a_len; i++) | 348 for (octave_idx_type i = 0; i < a_len; i++) |
349 xelem (r+i, c+i) = a.elem (i, i); | 349 xelem (r+i, c+i) = a.elem (i, i); |
350 } | 350 } |
351 | 351 |
352 return *this; | 352 return *this; |
353 } | 353 } |
354 | 354 |
355 ComplexMatrix& | 355 ComplexMatrix& |
356 ComplexMatrix::insert (const ComplexMatrix& a, int r, int c) | 356 ComplexMatrix::insert (const ComplexMatrix& a, octave_idx_type r, octave_idx_type c) |
357 { | 357 { |
358 Array2<Complex>::insert (a, r, c); | 358 Array2<Complex>::insert (a, r, c); |
359 return *this; | 359 return *this; |
360 } | 360 } |
361 | 361 |
362 ComplexMatrix& | 362 ComplexMatrix& |
363 ComplexMatrix::insert (const ComplexRowVector& a, int r, int c) | 363 ComplexMatrix::insert (const ComplexRowVector& a, octave_idx_type r, octave_idx_type c) |
364 { | 364 { |
365 int a_len = a.length (); | 365 octave_idx_type a_len = a.length (); |
366 if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) | 366 if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) |
367 { | 367 { |
368 (*current_liboctave_error_handler) ("range error for insert"); | 368 (*current_liboctave_error_handler) ("range error for insert"); |
369 return *this; | 369 return *this; |
370 } | 370 } |
371 | 371 |
372 for (int i = 0; i < a_len; i++) | 372 for (octave_idx_type i = 0; i < a_len; i++) |
373 elem (r, c+i) = a.elem (i); | 373 elem (r, c+i) = a.elem (i); |
374 | 374 |
375 return *this; | 375 return *this; |
376 } | 376 } |
377 | 377 |
378 ComplexMatrix& | 378 ComplexMatrix& |
379 ComplexMatrix::insert (const ComplexColumnVector& a, int r, int c) | 379 ComplexMatrix::insert (const ComplexColumnVector& a, octave_idx_type r, octave_idx_type c) |
380 { | 380 { |
381 int a_len = a.length (); | 381 octave_idx_type a_len = a.length (); |
382 | 382 |
383 if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) | 383 if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) |
384 { | 384 { |
385 (*current_liboctave_error_handler) ("range error for insert"); | 385 (*current_liboctave_error_handler) ("range error for insert"); |
386 return *this; | 386 return *this; |
388 | 388 |
389 if (a_len > 0) | 389 if (a_len > 0) |
390 { | 390 { |
391 make_unique (); | 391 make_unique (); |
392 | 392 |
393 for (int i = 0; i < a_len; i++) | 393 for (octave_idx_type i = 0; i < a_len; i++) |
394 xelem (r+i, c) = a.elem (i); | 394 xelem (r+i, c) = a.elem (i); |
395 } | 395 } |
396 | 396 |
397 return *this; | 397 return *this; |
398 } | 398 } |
399 | 399 |
400 ComplexMatrix& | 400 ComplexMatrix& |
401 ComplexMatrix::insert (const ComplexDiagMatrix& a, int r, int c) | 401 ComplexMatrix::insert (const ComplexDiagMatrix& a, octave_idx_type r, octave_idx_type c) |
402 { | 402 { |
403 int a_nr = a.rows (); | 403 octave_idx_type a_nr = a.rows (); |
404 int a_nc = a.cols (); | 404 octave_idx_type a_nc = a.cols (); |
405 | 405 |
406 if (r < 0 || r + a_nr > rows () || c < 0 || c + a_nc > cols ()) | 406 if (r < 0 || r + a_nr > rows () || c < 0 || c + a_nc > cols ()) |
407 { | 407 { |
408 (*current_liboctave_error_handler) ("range error for insert"); | 408 (*current_liboctave_error_handler) ("range error for insert"); |
409 return *this; | 409 return *this; |
410 } | 410 } |
411 | 411 |
412 fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1); | 412 fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1); |
413 | 413 |
414 int a_len = a.length (); | 414 octave_idx_type a_len = a.length (); |
415 | 415 |
416 if (a_len > 0) | 416 if (a_len > 0) |
417 { | 417 { |
418 make_unique (); | 418 make_unique (); |
419 | 419 |
420 for (int i = 0; i < a_len; i++) | 420 for (octave_idx_type i = 0; i < a_len; i++) |
421 xelem (r+i, c+i) = a.elem (i, i); | 421 xelem (r+i, c+i) = a.elem (i, i); |
422 } | 422 } |
423 | 423 |
424 return *this; | 424 return *this; |
425 } | 425 } |
426 | 426 |
427 ComplexMatrix& | 427 ComplexMatrix& |
428 ComplexMatrix::fill (double val) | 428 ComplexMatrix::fill (double val) |
429 { | 429 { |
430 int nr = rows (); | 430 octave_idx_type nr = rows (); |
431 int nc = cols (); | 431 octave_idx_type nc = cols (); |
432 | 432 |
433 if (nr > 0 && nc > 0) | 433 if (nr > 0 && nc > 0) |
434 { | 434 { |
435 make_unique (); | 435 make_unique (); |
436 | 436 |
437 for (int j = 0; j < nc; j++) | 437 for (octave_idx_type j = 0; j < nc; j++) |
438 for (int i = 0; i < nr; i++) | 438 for (octave_idx_type i = 0; i < nr; i++) |
439 xelem (i, j) = val; | 439 xelem (i, j) = val; |
440 } | 440 } |
441 | 441 |
442 return *this; | 442 return *this; |
443 } | 443 } |
444 | 444 |
445 ComplexMatrix& | 445 ComplexMatrix& |
446 ComplexMatrix::fill (const Complex& val) | 446 ComplexMatrix::fill (const Complex& val) |
447 { | 447 { |
448 int nr = rows (); | 448 octave_idx_type nr = rows (); |
449 int nc = cols (); | 449 octave_idx_type nc = cols (); |
450 | 450 |
451 if (nr > 0 && nc > 0) | 451 if (nr > 0 && nc > 0) |
452 { | 452 { |
453 make_unique (); | 453 make_unique (); |
454 | 454 |
455 for (int j = 0; j < nc; j++) | 455 for (octave_idx_type j = 0; j < nc; j++) |
456 for (int i = 0; i < nr; i++) | 456 for (octave_idx_type i = 0; i < nr; i++) |
457 xelem (i, j) = val; | 457 xelem (i, j) = val; |
458 } | 458 } |
459 | 459 |
460 return *this; | 460 return *this; |
461 } | 461 } |
462 | 462 |
463 ComplexMatrix& | 463 ComplexMatrix& |
464 ComplexMatrix::fill (double val, int r1, int c1, int r2, int c2) | 464 ComplexMatrix::fill (double val, octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) |
465 { | 465 { |
466 int nr = rows (); | 466 octave_idx_type nr = rows (); |
467 int nc = cols (); | 467 octave_idx_type nc = cols (); |
468 | 468 |
469 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0 | 469 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0 |
470 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc) | 470 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc) |
471 { | 471 { |
472 (*current_liboctave_error_handler) ("range error for fill"); | 472 (*current_liboctave_error_handler) ("range error for fill"); |
473 return *this; | 473 return *this; |
474 } | 474 } |
475 | 475 |
476 if (r1 > r2) { int tmp = r1; r1 = r2; r2 = tmp; } | 476 if (r1 > r2) { octave_idx_type tmp = r1; r1 = r2; r2 = tmp; } |
477 if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; } | 477 if (c1 > c2) { octave_idx_type tmp = c1; c1 = c2; c2 = tmp; } |
478 | 478 |
479 if (r2 >= r1 && c2 >= c1) | 479 if (r2 >= r1 && c2 >= c1) |
480 { | 480 { |
481 make_unique (); | 481 make_unique (); |
482 | 482 |
483 for (int j = c1; j <= c2; j++) | 483 for (octave_idx_type j = c1; j <= c2; j++) |
484 for (int i = r1; i <= r2; i++) | 484 for (octave_idx_type i = r1; i <= r2; i++) |
485 xelem (i, j) = val; | 485 xelem (i, j) = val; |
486 } | 486 } |
487 | 487 |
488 return *this; | 488 return *this; |
489 } | 489 } |
490 | 490 |
491 ComplexMatrix& | 491 ComplexMatrix& |
492 ComplexMatrix::fill (const Complex& val, int r1, int c1, int r2, int c2) | 492 ComplexMatrix::fill (const Complex& val, octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) |
493 { | 493 { |
494 int nr = rows (); | 494 octave_idx_type nr = rows (); |
495 int nc = cols (); | 495 octave_idx_type nc = cols (); |
496 | 496 |
497 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0 | 497 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0 |
498 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc) | 498 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc) |
499 { | 499 { |
500 (*current_liboctave_error_handler) ("range error for fill"); | 500 (*current_liboctave_error_handler) ("range error for fill"); |
501 return *this; | 501 return *this; |
502 } | 502 } |
503 | 503 |
504 if (r1 > r2) { int tmp = r1; r1 = r2; r2 = tmp; } | 504 if (r1 > r2) { octave_idx_type tmp = r1; r1 = r2; r2 = tmp; } |
505 if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; } | 505 if (c1 > c2) { octave_idx_type tmp = c1; c1 = c2; c2 = tmp; } |
506 | 506 |
507 if (r2 >= r1 && c2 >=c1) | 507 if (r2 >= r1 && c2 >=c1) |
508 { | 508 { |
509 make_unique (); | 509 make_unique (); |
510 | 510 |
511 for (int j = c1; j <= c2; j++) | 511 for (octave_idx_type j = c1; j <= c2; j++) |
512 for (int i = r1; i <= r2; i++) | 512 for (octave_idx_type i = r1; i <= r2; i++) |
513 xelem (i, j) = val; | 513 xelem (i, j) = val; |
514 } | 514 } |
515 | 515 |
516 return *this; | 516 return *this; |
517 } | 517 } |
518 | 518 |
519 ComplexMatrix | 519 ComplexMatrix |
520 ComplexMatrix::append (const Matrix& a) const | 520 ComplexMatrix::append (const Matrix& a) const |
521 { | 521 { |
522 int nr = rows (); | 522 octave_idx_type nr = rows (); |
523 int nc = cols (); | 523 octave_idx_type nc = cols (); |
524 if (nr != a.rows ()) | 524 if (nr != a.rows ()) |
525 { | 525 { |
526 (*current_liboctave_error_handler) ("row dimension mismatch for append"); | 526 (*current_liboctave_error_handler) ("row dimension mismatch for append"); |
527 return *this; | 527 return *this; |
528 } | 528 } |
529 | 529 |
530 int nc_insert = nc; | 530 octave_idx_type nc_insert = nc; |
531 ComplexMatrix retval (nr, nc + a.cols ()); | 531 ComplexMatrix retval (nr, nc + a.cols ()); |
532 retval.insert (*this, 0, 0); | 532 retval.insert (*this, 0, 0); |
533 retval.insert (a, 0, nc_insert); | 533 retval.insert (a, 0, nc_insert); |
534 return retval; | 534 return retval; |
535 } | 535 } |
536 | 536 |
537 ComplexMatrix | 537 ComplexMatrix |
538 ComplexMatrix::append (const RowVector& a) const | 538 ComplexMatrix::append (const RowVector& a) const |
539 { | 539 { |
540 int nr = rows (); | 540 octave_idx_type nr = rows (); |
541 int nc = cols (); | 541 octave_idx_type nc = cols (); |
542 if (nr != 1) | 542 if (nr != 1) |
543 { | 543 { |
544 (*current_liboctave_error_handler) ("row dimension mismatch for append"); | 544 (*current_liboctave_error_handler) ("row dimension mismatch for append"); |
545 return *this; | 545 return *this; |
546 } | 546 } |
547 | 547 |
548 int nc_insert = nc; | 548 octave_idx_type nc_insert = nc; |
549 ComplexMatrix retval (nr, nc + a.length ()); | 549 ComplexMatrix retval (nr, nc + a.length ()); |
550 retval.insert (*this, 0, 0); | 550 retval.insert (*this, 0, 0); |
551 retval.insert (a, 0, nc_insert); | 551 retval.insert (a, 0, nc_insert); |
552 return retval; | 552 return retval; |
553 } | 553 } |
554 | 554 |
555 ComplexMatrix | 555 ComplexMatrix |
556 ComplexMatrix::append (const ColumnVector& a) const | 556 ComplexMatrix::append (const ColumnVector& a) const |
557 { | 557 { |
558 int nr = rows (); | 558 octave_idx_type nr = rows (); |
559 int nc = cols (); | 559 octave_idx_type nc = cols (); |
560 if (nr != a.length ()) | 560 if (nr != a.length ()) |
561 { | 561 { |
562 (*current_liboctave_error_handler) ("row dimension mismatch for append"); | 562 (*current_liboctave_error_handler) ("row dimension mismatch for append"); |
563 return *this; | 563 return *this; |
564 } | 564 } |
565 | 565 |
566 int nc_insert = nc; | 566 octave_idx_type nc_insert = nc; |
567 ComplexMatrix retval (nr, nc + 1); | 567 ComplexMatrix retval (nr, nc + 1); |
568 retval.insert (*this, 0, 0); | 568 retval.insert (*this, 0, 0); |
569 retval.insert (a, 0, nc_insert); | 569 retval.insert (a, 0, nc_insert); |
570 return retval; | 570 return retval; |
571 } | 571 } |
572 | 572 |
573 ComplexMatrix | 573 ComplexMatrix |
574 ComplexMatrix::append (const DiagMatrix& a) const | 574 ComplexMatrix::append (const DiagMatrix& a) const |
575 { | 575 { |
576 int nr = rows (); | 576 octave_idx_type nr = rows (); |
577 int nc = cols (); | 577 octave_idx_type nc = cols (); |
578 if (nr != a.rows ()) | 578 if (nr != a.rows ()) |
579 { | 579 { |
580 (*current_liboctave_error_handler) ("row dimension mismatch for append"); | 580 (*current_liboctave_error_handler) ("row dimension mismatch for append"); |
581 return *this; | 581 return *this; |
582 } | 582 } |
583 | 583 |
584 int nc_insert = nc; | 584 octave_idx_type nc_insert = nc; |
585 ComplexMatrix retval (nr, nc + a.cols ()); | 585 ComplexMatrix retval (nr, nc + a.cols ()); |
586 retval.insert (*this, 0, 0); | 586 retval.insert (*this, 0, 0); |
587 retval.insert (a, 0, nc_insert); | 587 retval.insert (a, 0, nc_insert); |
588 return retval; | 588 return retval; |
589 } | 589 } |
590 | 590 |
591 ComplexMatrix | 591 ComplexMatrix |
592 ComplexMatrix::append (const ComplexMatrix& a) const | 592 ComplexMatrix::append (const ComplexMatrix& a) const |
593 { | 593 { |
594 int nr = rows (); | 594 octave_idx_type nr = rows (); |
595 int nc = cols (); | 595 octave_idx_type nc = cols (); |
596 if (nr != a.rows ()) | 596 if (nr != a.rows ()) |
597 { | 597 { |
598 (*current_liboctave_error_handler) ("row dimension mismatch for append"); | 598 (*current_liboctave_error_handler) ("row dimension mismatch for append"); |
599 return *this; | 599 return *this; |
600 } | 600 } |
601 | 601 |
602 int nc_insert = nc; | 602 octave_idx_type nc_insert = nc; |
603 ComplexMatrix retval (nr, nc + a.cols ()); | 603 ComplexMatrix retval (nr, nc + a.cols ()); |
604 retval.insert (*this, 0, 0); | 604 retval.insert (*this, 0, 0); |
605 retval.insert (a, 0, nc_insert); | 605 retval.insert (a, 0, nc_insert); |
606 return retval; | 606 return retval; |
607 } | 607 } |
608 | 608 |
609 ComplexMatrix | 609 ComplexMatrix |
610 ComplexMatrix::append (const ComplexRowVector& a) const | 610 ComplexMatrix::append (const ComplexRowVector& a) const |
611 { | 611 { |
612 int nr = rows (); | 612 octave_idx_type nr = rows (); |
613 int nc = cols (); | 613 octave_idx_type nc = cols (); |
614 if (nr != 1) | 614 if (nr != 1) |
615 { | 615 { |
616 (*current_liboctave_error_handler) ("row dimension mismatch for append"); | 616 (*current_liboctave_error_handler) ("row dimension mismatch for append"); |
617 return *this; | 617 return *this; |
618 } | 618 } |
619 | 619 |
620 int nc_insert = nc; | 620 octave_idx_type nc_insert = nc; |
621 ComplexMatrix retval (nr, nc + a.length ()); | 621 ComplexMatrix retval (nr, nc + a.length ()); |
622 retval.insert (*this, 0, 0); | 622 retval.insert (*this, 0, 0); |
623 retval.insert (a, 0, nc_insert); | 623 retval.insert (a, 0, nc_insert); |
624 return retval; | 624 return retval; |
625 } | 625 } |
626 | 626 |
627 ComplexMatrix | 627 ComplexMatrix |
628 ComplexMatrix::append (const ComplexColumnVector& a) const | 628 ComplexMatrix::append (const ComplexColumnVector& a) const |
629 { | 629 { |
630 int nr = rows (); | 630 octave_idx_type nr = rows (); |
631 int nc = cols (); | 631 octave_idx_type nc = cols (); |
632 if (nr != a.length ()) | 632 if (nr != a.length ()) |
633 { | 633 { |
634 (*current_liboctave_error_handler) ("row dimension mismatch for append"); | 634 (*current_liboctave_error_handler) ("row dimension mismatch for append"); |
635 return *this; | 635 return *this; |
636 } | 636 } |
637 | 637 |
638 int nc_insert = nc; | 638 octave_idx_type nc_insert = nc; |
639 ComplexMatrix retval (nr, nc + 1); | 639 ComplexMatrix retval (nr, nc + 1); |
640 retval.insert (*this, 0, 0); | 640 retval.insert (*this, 0, 0); |
641 retval.insert (a, 0, nc_insert); | 641 retval.insert (a, 0, nc_insert); |
642 return retval; | 642 return retval; |
643 } | 643 } |
644 | 644 |
645 ComplexMatrix | 645 ComplexMatrix |
646 ComplexMatrix::append (const ComplexDiagMatrix& a) const | 646 ComplexMatrix::append (const ComplexDiagMatrix& a) const |
647 { | 647 { |
648 int nr = rows (); | 648 octave_idx_type nr = rows (); |
649 int nc = cols (); | 649 octave_idx_type nc = cols (); |
650 if (nr != a.rows ()) | 650 if (nr != a.rows ()) |
651 { | 651 { |
652 (*current_liboctave_error_handler) ("row dimension mismatch for append"); | 652 (*current_liboctave_error_handler) ("row dimension mismatch for append"); |
653 return *this; | 653 return *this; |
654 } | 654 } |
655 | 655 |
656 int nc_insert = nc; | 656 octave_idx_type nc_insert = nc; |
657 ComplexMatrix retval (nr, nc + a.cols ()); | 657 ComplexMatrix retval (nr, nc + a.cols ()); |
658 retval.insert (*this, 0, 0); | 658 retval.insert (*this, 0, 0); |
659 retval.insert (a, 0, nc_insert); | 659 retval.insert (a, 0, nc_insert); |
660 return retval; | 660 return retval; |
661 } | 661 } |
662 | 662 |
663 ComplexMatrix | 663 ComplexMatrix |
664 ComplexMatrix::stack (const Matrix& a) const | 664 ComplexMatrix::stack (const Matrix& a) const |
665 { | 665 { |
666 int nr = rows (); | 666 octave_idx_type nr = rows (); |
667 int nc = cols (); | 667 octave_idx_type nc = cols (); |
668 if (nc != a.cols ()) | 668 if (nc != a.cols ()) |
669 { | 669 { |
670 (*current_liboctave_error_handler) | 670 (*current_liboctave_error_handler) |
671 ("column dimension mismatch for stack"); | 671 ("column dimension mismatch for stack"); |
672 return *this; | 672 return *this; |
673 } | 673 } |
674 | 674 |
675 int nr_insert = nr; | 675 octave_idx_type nr_insert = nr; |
676 ComplexMatrix retval (nr + a.rows (), nc); | 676 ComplexMatrix retval (nr + a.rows (), nc); |
677 retval.insert (*this, 0, 0); | 677 retval.insert (*this, 0, 0); |
678 retval.insert (a, nr_insert, 0); | 678 retval.insert (a, nr_insert, 0); |
679 return retval; | 679 return retval; |
680 } | 680 } |
681 | 681 |
682 ComplexMatrix | 682 ComplexMatrix |
683 ComplexMatrix::stack (const RowVector& a) const | 683 ComplexMatrix::stack (const RowVector& a) const |
684 { | 684 { |
685 int nr = rows (); | 685 octave_idx_type nr = rows (); |
686 int nc = cols (); | 686 octave_idx_type nc = cols (); |
687 if (nc != a.length ()) | 687 if (nc != a.length ()) |
688 { | 688 { |
689 (*current_liboctave_error_handler) | 689 (*current_liboctave_error_handler) |
690 ("column dimension mismatch for stack"); | 690 ("column dimension mismatch for stack"); |
691 return *this; | 691 return *this; |
692 } | 692 } |
693 | 693 |
694 int nr_insert = nr; | 694 octave_idx_type nr_insert = nr; |
695 ComplexMatrix retval (nr + 1, nc); | 695 ComplexMatrix retval (nr + 1, nc); |
696 retval.insert (*this, 0, 0); | 696 retval.insert (*this, 0, 0); |
697 retval.insert (a, nr_insert, 0); | 697 retval.insert (a, nr_insert, 0); |
698 return retval; | 698 return retval; |
699 } | 699 } |
700 | 700 |
701 ComplexMatrix | 701 ComplexMatrix |
702 ComplexMatrix::stack (const ColumnVector& a) const | 702 ComplexMatrix::stack (const ColumnVector& a) const |
703 { | 703 { |
704 int nr = rows (); | 704 octave_idx_type nr = rows (); |
705 int nc = cols (); | 705 octave_idx_type nc = cols (); |
706 if (nc != 1) | 706 if (nc != 1) |
707 { | 707 { |
708 (*current_liboctave_error_handler) | 708 (*current_liboctave_error_handler) |
709 ("column dimension mismatch for stack"); | 709 ("column dimension mismatch for stack"); |
710 return *this; | 710 return *this; |
711 } | 711 } |
712 | 712 |
713 int nr_insert = nr; | 713 octave_idx_type nr_insert = nr; |
714 ComplexMatrix retval (nr + a.length (), nc); | 714 ComplexMatrix retval (nr + a.length (), nc); |
715 retval.insert (*this, 0, 0); | 715 retval.insert (*this, 0, 0); |
716 retval.insert (a, nr_insert, 0); | 716 retval.insert (a, nr_insert, 0); |
717 return retval; | 717 return retval; |
718 } | 718 } |
719 | 719 |
720 ComplexMatrix | 720 ComplexMatrix |
721 ComplexMatrix::stack (const DiagMatrix& a) const | 721 ComplexMatrix::stack (const DiagMatrix& a) const |
722 { | 722 { |
723 int nr = rows (); | 723 octave_idx_type nr = rows (); |
724 int nc = cols (); | 724 octave_idx_type nc = cols (); |
725 if (nc != a.cols ()) | 725 if (nc != a.cols ()) |
726 { | 726 { |
727 (*current_liboctave_error_handler) | 727 (*current_liboctave_error_handler) |
728 ("column dimension mismatch for stack"); | 728 ("column dimension mismatch for stack"); |
729 return *this; | 729 return *this; |
730 } | 730 } |
731 | 731 |
732 int nr_insert = nr; | 732 octave_idx_type nr_insert = nr; |
733 ComplexMatrix retval (nr + a.rows (), nc); | 733 ComplexMatrix retval (nr + a.rows (), nc); |
734 retval.insert (*this, 0, 0); | 734 retval.insert (*this, 0, 0); |
735 retval.insert (a, nr_insert, 0); | 735 retval.insert (a, nr_insert, 0); |
736 return retval; | 736 return retval; |
737 } | 737 } |
738 | 738 |
739 ComplexMatrix | 739 ComplexMatrix |
740 ComplexMatrix::stack (const ComplexMatrix& a) const | 740 ComplexMatrix::stack (const ComplexMatrix& a) const |
741 { | 741 { |
742 int nr = rows (); | 742 octave_idx_type nr = rows (); |
743 int nc = cols (); | 743 octave_idx_type nc = cols (); |
744 if (nc != a.cols ()) | 744 if (nc != a.cols ()) |
745 { | 745 { |
746 (*current_liboctave_error_handler) | 746 (*current_liboctave_error_handler) |
747 ("column dimension mismatch for stack"); | 747 ("column dimension mismatch for stack"); |
748 return *this; | 748 return *this; |
749 } | 749 } |
750 | 750 |
751 int nr_insert = nr; | 751 octave_idx_type nr_insert = nr; |
752 ComplexMatrix retval (nr + a.rows (), nc); | 752 ComplexMatrix retval (nr + a.rows (), nc); |
753 retval.insert (*this, 0, 0); | 753 retval.insert (*this, 0, 0); |
754 retval.insert (a, nr_insert, 0); | 754 retval.insert (a, nr_insert, 0); |
755 return retval; | 755 return retval; |
756 } | 756 } |
757 | 757 |
758 ComplexMatrix | 758 ComplexMatrix |
759 ComplexMatrix::stack (const ComplexRowVector& a) const | 759 ComplexMatrix::stack (const ComplexRowVector& a) const |
760 { | 760 { |
761 int nr = rows (); | 761 octave_idx_type nr = rows (); |
762 int nc = cols (); | 762 octave_idx_type nc = cols (); |
763 if (nc != a.length ()) | 763 if (nc != a.length ()) |
764 { | 764 { |
765 (*current_liboctave_error_handler) | 765 (*current_liboctave_error_handler) |
766 ("column dimension mismatch for stack"); | 766 ("column dimension mismatch for stack"); |
767 return *this; | 767 return *this; |
768 } | 768 } |
769 | 769 |
770 int nr_insert = nr; | 770 octave_idx_type nr_insert = nr; |
771 ComplexMatrix retval (nr + 1, nc); | 771 ComplexMatrix retval (nr + 1, nc); |
772 retval.insert (*this, 0, 0); | 772 retval.insert (*this, 0, 0); |
773 retval.insert (a, nr_insert, 0); | 773 retval.insert (a, nr_insert, 0); |
774 return retval; | 774 return retval; |
775 } | 775 } |
776 | 776 |
777 ComplexMatrix | 777 ComplexMatrix |
778 ComplexMatrix::stack (const ComplexColumnVector& a) const | 778 ComplexMatrix::stack (const ComplexColumnVector& a) const |
779 { | 779 { |
780 int nr = rows (); | 780 octave_idx_type nr = rows (); |
781 int nc = cols (); | 781 octave_idx_type nc = cols (); |
782 if (nc != 1) | 782 if (nc != 1) |
783 { | 783 { |
784 (*current_liboctave_error_handler) | 784 (*current_liboctave_error_handler) |
785 ("column dimension mismatch for stack"); | 785 ("column dimension mismatch for stack"); |
786 return *this; | 786 return *this; |
787 } | 787 } |
788 | 788 |
789 int nr_insert = nr; | 789 octave_idx_type nr_insert = nr; |
790 ComplexMatrix retval (nr + a.length (), nc); | 790 ComplexMatrix retval (nr + a.length (), nc); |
791 retval.insert (*this, 0, 0); | 791 retval.insert (*this, 0, 0); |
792 retval.insert (a, nr_insert, 0); | 792 retval.insert (a, nr_insert, 0); |
793 return retval; | 793 return retval; |
794 } | 794 } |
795 | 795 |
796 ComplexMatrix | 796 ComplexMatrix |
797 ComplexMatrix::stack (const ComplexDiagMatrix& a) const | 797 ComplexMatrix::stack (const ComplexDiagMatrix& a) const |
798 { | 798 { |
799 int nr = rows (); | 799 octave_idx_type nr = rows (); |
800 int nc = cols (); | 800 octave_idx_type nc = cols (); |
801 if (nc != a.cols ()) | 801 if (nc != a.cols ()) |
802 { | 802 { |
803 (*current_liboctave_error_handler) | 803 (*current_liboctave_error_handler) |
804 ("column dimension mismatch for stack"); | 804 ("column dimension mismatch for stack"); |
805 return *this; | 805 return *this; |
806 } | 806 } |
807 | 807 |
808 int nr_insert = nr; | 808 octave_idx_type nr_insert = nr; |
809 ComplexMatrix retval (nr + a.rows (), nc); | 809 ComplexMatrix retval (nr + a.rows (), nc); |
810 retval.insert (*this, 0, 0); | 810 retval.insert (*this, 0, 0); |
811 retval.insert (a, nr_insert, 0); | 811 retval.insert (a, nr_insert, 0); |
812 return retval; | 812 return retval; |
813 } | 813 } |
814 | 814 |
815 ComplexMatrix | 815 ComplexMatrix |
816 ComplexMatrix::hermitian (void) const | 816 ComplexMatrix::hermitian (void) const |
817 { | 817 { |
818 int nr = rows (); | 818 octave_idx_type nr = rows (); |
819 int nc = cols (); | 819 octave_idx_type nc = cols (); |
820 ComplexMatrix result; | 820 ComplexMatrix result; |
821 if (length () > 0) | 821 if (length () > 0) |
822 { | 822 { |
823 result.resize (nc, nr); | 823 result.resize (nc, nr); |
824 for (int j = 0; j < nc; j++) | 824 for (octave_idx_type j = 0; j < nc; j++) |
825 for (int i = 0; i < nr; i++) | 825 for (octave_idx_type i = 0; i < nr; i++) |
826 result.elem (j, i) = conj (elem (i, j)); | 826 result.elem (j, i) = conj (elem (i, j)); |
827 } | 827 } |
828 return result; | 828 return result; |
829 } | 829 } |
830 | 830 |
831 ComplexMatrix | 831 ComplexMatrix |
832 conj (const ComplexMatrix& a) | 832 conj (const ComplexMatrix& a) |
833 { | 833 { |
834 int a_len = a.length (); | 834 octave_idx_type a_len = a.length (); |
835 ComplexMatrix retval; | 835 ComplexMatrix retval; |
836 if (a_len > 0) | 836 if (a_len > 0) |
837 retval = ComplexMatrix (mx_inline_conj_dup (a.data (), a_len), | 837 retval = ComplexMatrix (mx_inline_conj_dup (a.data (), a_len), |
838 a.rows (), a.cols ()); | 838 a.rows (), a.cols ()); |
839 return retval; | 839 return retval; |
840 } | 840 } |
841 | 841 |
842 // resize is the destructive equivalent for this one | 842 // resize is the destructive equivalent for this one |
843 | 843 |
844 ComplexMatrix | 844 ComplexMatrix |
845 ComplexMatrix::extract (int r1, int c1, int r2, int c2) const | 845 ComplexMatrix::extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const |
846 { | 846 { |
847 if (r1 > r2) { int tmp = r1; r1 = r2; r2 = tmp; } | 847 if (r1 > r2) { octave_idx_type tmp = r1; r1 = r2; r2 = tmp; } |
848 if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; } | 848 if (c1 > c2) { octave_idx_type tmp = c1; c1 = c2; c2 = tmp; } |
849 | 849 |
850 int new_r = r2 - r1 + 1; | 850 octave_idx_type new_r = r2 - r1 + 1; |
851 int new_c = c2 - c1 + 1; | 851 octave_idx_type new_c = c2 - c1 + 1; |
852 | 852 |
853 ComplexMatrix result (new_r, new_c); | 853 ComplexMatrix result (new_r, new_c); |
854 | 854 |
855 for (int j = 0; j < new_c; j++) | 855 for (octave_idx_type j = 0; j < new_c; j++) |
856 for (int i = 0; i < new_r; i++) | 856 for (octave_idx_type i = 0; i < new_r; i++) |
857 result.xelem (i, j) = elem (r1+i, c1+j); | 857 result.xelem (i, j) = elem (r1+i, c1+j); |
858 | 858 |
859 return result; | 859 return result; |
860 } | 860 } |
861 | 861 |
862 ComplexMatrix | 862 ComplexMatrix |
863 ComplexMatrix::extract_n (int r1, int c1, int nr, int nc) const | 863 ComplexMatrix::extract_n (octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const |
864 { | 864 { |
865 ComplexMatrix result (nr, nc); | 865 ComplexMatrix result (nr, nc); |
866 | 866 |
867 for (int j = 0; j < nc; j++) | 867 for (octave_idx_type j = 0; j < nc; j++) |
868 for (int i = 0; i < nr; i++) | 868 for (octave_idx_type i = 0; i < nr; i++) |
869 result.xelem (i, j) = elem (r1+i, c1+j); | 869 result.xelem (i, j) = elem (r1+i, c1+j); |
870 | 870 |
871 return result; | 871 return result; |
872 } | 872 } |
873 | 873 |
874 // extract row or column i. | 874 // extract row or column i. |
875 | 875 |
876 ComplexRowVector | 876 ComplexRowVector |
877 ComplexMatrix::row (int i) const | 877 ComplexMatrix::row (octave_idx_type i) const |
878 { | 878 { |
879 int nc = cols (); | 879 octave_idx_type nc = cols (); |
880 if (i < 0 || i >= rows ()) | 880 if (i < 0 || i >= rows ()) |
881 { | 881 { |
882 (*current_liboctave_error_handler) ("invalid row selection"); | 882 (*current_liboctave_error_handler) ("invalid row selection"); |
883 return ComplexRowVector (); | 883 return ComplexRowVector (); |
884 } | 884 } |
885 | 885 |
886 ComplexRowVector retval (nc); | 886 ComplexRowVector retval (nc); |
887 for (int j = 0; j < cols (); j++) | 887 for (octave_idx_type j = 0; j < cols (); j++) |
888 retval.xelem (j) = elem (i, j); | 888 retval.xelem (j) = elem (i, j); |
889 | 889 |
890 return retval; | 890 return retval; |
891 } | 891 } |
892 | 892 |
899 return ComplexRowVector (); | 899 return ComplexRowVector (); |
900 } | 900 } |
901 | 901 |
902 char c = *s; | 902 char c = *s; |
903 if (c == 'f' || c == 'F') | 903 if (c == 'f' || c == 'F') |
904 return row (0); | 904 return row (static_cast<octave_idx_type>(0)); |
905 else if (c == 'l' || c == 'L') | 905 else if (c == 'l' || c == 'L') |
906 return row (rows () - 1); | 906 return row (rows () - 1); |
907 else | 907 else |
908 { | 908 { |
909 (*current_liboctave_error_handler) ("invalid row selection"); | 909 (*current_liboctave_error_handler) ("invalid row selection"); |
910 return ComplexRowVector (); | 910 return ComplexRowVector (); |
911 } | 911 } |
912 } | 912 } |
913 | 913 |
914 ComplexColumnVector | 914 ComplexColumnVector |
915 ComplexMatrix::column (int i) const | 915 ComplexMatrix::column (octave_idx_type i) const |
916 { | 916 { |
917 int nr = rows (); | 917 octave_idx_type nr = rows (); |
918 if (i < 0 || i >= cols ()) | 918 if (i < 0 || i >= cols ()) |
919 { | 919 { |
920 (*current_liboctave_error_handler) ("invalid column selection"); | 920 (*current_liboctave_error_handler) ("invalid column selection"); |
921 return ComplexColumnVector (); | 921 return ComplexColumnVector (); |
922 } | 922 } |
923 | 923 |
924 ComplexColumnVector retval (nr); | 924 ComplexColumnVector retval (nr); |
925 for (int j = 0; j < nr; j++) | 925 for (octave_idx_type j = 0; j < nr; j++) |
926 retval.xelem (j) = elem (j, i); | 926 retval.xelem (j) = elem (j, i); |
927 | 927 |
928 return retval; | 928 return retval; |
929 } | 929 } |
930 | 930 |
937 return ComplexColumnVector (); | 937 return ComplexColumnVector (); |
938 } | 938 } |
939 | 939 |
940 char c = *s; | 940 char c = *s; |
941 if (c == 'f' || c == 'F') | 941 if (c == 'f' || c == 'F') |
942 return column (0); | 942 return column (static_cast<octave_idx_type>(0)); |
943 else if (c == 'l' || c == 'L') | 943 else if (c == 'l' || c == 'L') |
944 return column (cols () - 1); | 944 return column (cols () - 1); |
945 else | 945 else |
946 { | 946 { |
947 (*current_liboctave_error_handler) ("invalid column selection"); | 947 (*current_liboctave_error_handler) ("invalid column selection"); |
950 } | 950 } |
951 | 951 |
952 ComplexMatrix | 952 ComplexMatrix |
953 ComplexMatrix::inverse (void) const | 953 ComplexMatrix::inverse (void) const |
954 { | 954 { |
955 int info; | 955 octave_idx_type info; |
956 double rcond; | 956 double rcond; |
957 return inverse (info, rcond, 0, 0); | 957 return inverse (info, rcond, 0, 0); |
958 } | 958 } |
959 | 959 |
960 ComplexMatrix | 960 ComplexMatrix |
961 ComplexMatrix::inverse (int& info) const | 961 ComplexMatrix::inverse (octave_idx_type& info) const |
962 { | 962 { |
963 double rcond; | 963 double rcond; |
964 return inverse (info, rcond, 0, 0); | 964 return inverse (info, rcond, 0, 0); |
965 } | 965 } |
966 | 966 |
967 ComplexMatrix | 967 ComplexMatrix |
968 ComplexMatrix::inverse (int& info, double& rcond, int force, | 968 ComplexMatrix::inverse (octave_idx_type& info, double& rcond, int force, |
969 int calc_cond) const | 969 int calc_cond) const |
970 { | 970 { |
971 ComplexMatrix retval; | 971 ComplexMatrix retval; |
972 | 972 |
973 int nr = rows (); | 973 octave_idx_type nr = rows (); |
974 int nc = cols (); | 974 octave_idx_type nc = cols (); |
975 | 975 |
976 if (nr != nc) | 976 if (nr != nc) |
977 (*current_liboctave_error_handler) ("inverse requires square matrix"); | 977 (*current_liboctave_error_handler) ("inverse requires square matrix"); |
978 else | 978 else |
979 { | 979 { |
980 Array<int> ipvt (nr); | 980 Array<octave_idx_type> ipvt (nr); |
981 int *pipvt = ipvt.fortran_vec (); | 981 octave_idx_type *pipvt = ipvt.fortran_vec (); |
982 | 982 |
983 retval = *this; | 983 retval = *this; |
984 Complex *tmp_data = retval.fortran_vec (); | 984 Complex *tmp_data = retval.fortran_vec (); |
985 | 985 |
986 Array<Complex> z(1); | 986 Array<Complex> z(1); |
987 int lwork = -1; | 987 octave_idx_type lwork = -1; |
988 | 988 |
989 // Query the optimum work array size. | 989 // Query the optimum work array size. |
990 | 990 |
991 F77_XFCN (zgetri, ZGETRI, (nc, tmp_data, nr, pipvt, | 991 F77_XFCN (zgetri, ZGETRI, (nc, tmp_data, nr, pipvt, |
992 z.fortran_vec (), lwork, info)); | 992 z.fortran_vec (), lwork, info)); |
996 (*current_liboctave_error_handler) | 996 (*current_liboctave_error_handler) |
997 ("unrecoverable error in zgetri"); | 997 ("unrecoverable error in zgetri"); |
998 return retval; | 998 return retval; |
999 } | 999 } |
1000 | 1000 |
1001 lwork = static_cast<int> (STD_OCTAVE::real(z(0))); | 1001 lwork = static_cast<octave_idx_type> (STD_OCTAVE::real(z(0))); |
1002 lwork = (lwork < 2 *nc ? 2*nc : lwork); | 1002 lwork = (lwork < 2 *nc ? 2*nc : lwork); |
1003 z.resize (lwork); | 1003 z.resize (lwork); |
1004 Complex *pz = z.fortran_vec (); | 1004 Complex *pz = z.fortran_vec (); |
1005 | 1005 |
1006 info = 0; | 1006 info = 0; |
1007 | 1007 |
1008 // Calculate the norm of the matrix, for later use. | 1008 // Calculate the norm of the matrix, for later use. |
1009 double anorm; | 1009 double anorm; |
1010 if (calc_cond) | 1010 if (calc_cond) |
1011 anorm = retval.abs().sum().row(0).max(); | 1011 anorm = retval.abs().sum().row(static_cast<octave_idx_type>(0)).max(); |
1012 | 1012 |
1013 F77_XFCN (zgetrf, ZGETRF, (nc, nc, tmp_data, nr, pipvt, info)); | 1013 F77_XFCN (zgetrf, ZGETRF, (nc, nc, tmp_data, nr, pipvt, info)); |
1014 | 1014 |
1015 if (f77_exception_encountered) | 1015 if (f77_exception_encountered) |
1016 (*current_liboctave_error_handler) ("unrecoverable error in zgetrf"); | 1016 (*current_liboctave_error_handler) ("unrecoverable error in zgetrf"); |
1021 if (info != 0) | 1021 if (info != 0) |
1022 info = -1; | 1022 info = -1; |
1023 else if (calc_cond) | 1023 else if (calc_cond) |
1024 { | 1024 { |
1025 // Now calculate the condition number for non-singular matrix. | 1025 // Now calculate the condition number for non-singular matrix. |
1026 int zgecon_info = 0; | 1026 octave_idx_type zgecon_info = 0; |
1027 char job = '1'; | 1027 char job = '1'; |
1028 Array<double> rz (2 * nc); | 1028 Array<double> rz (2 * nc); |
1029 double *prz = rz.fortran_vec (); | 1029 double *prz = rz.fortran_vec (); |
1030 F77_XFCN (zgecon, ZGECON, (F77_CONST_CHAR_ARG2 (&job, 1), | 1030 F77_XFCN (zgecon, ZGECON, (F77_CONST_CHAR_ARG2 (&job, 1), |
1031 nc, tmp_data, nr, anorm, | 1031 nc, tmp_data, nr, anorm, |
1042 | 1042 |
1043 if (info == -1 && ! force) | 1043 if (info == -1 && ! force) |
1044 retval = *this; // Restore contents. | 1044 retval = *this; // Restore contents. |
1045 else | 1045 else |
1046 { | 1046 { |
1047 int zgetri_info = 0; | 1047 octave_idx_type zgetri_info = 0; |
1048 | 1048 |
1049 F77_XFCN (zgetri, ZGETRI, (nc, tmp_data, nr, pipvt, | 1049 F77_XFCN (zgetri, ZGETRI, (nc, tmp_data, nr, pipvt, |
1050 pz, lwork, zgetri_info)); | 1050 pz, lwork, zgetri_info)); |
1051 | 1051 |
1052 if (f77_exception_encountered) | 1052 if (f77_exception_encountered) |
1073 ComplexMatrix U = result.left_singular_matrix (); | 1073 ComplexMatrix U = result.left_singular_matrix (); |
1074 ComplexMatrix V = result.right_singular_matrix (); | 1074 ComplexMatrix V = result.right_singular_matrix (); |
1075 | 1075 |
1076 ColumnVector sigma = S.diag (); | 1076 ColumnVector sigma = S.diag (); |
1077 | 1077 |
1078 int r = sigma.length () - 1; | 1078 octave_idx_type r = sigma.length () - 1; |
1079 int nr = rows (); | 1079 octave_idx_type nr = rows (); |
1080 int nc = cols (); | 1080 octave_idx_type nc = cols (); |
1081 | 1081 |
1082 if (tol <= 0.0) | 1082 if (tol <= 0.0) |
1083 { | 1083 { |
1084 if (nr > nc) | 1084 if (nr > nc) |
1085 tol = nr * sigma.elem (0) * DBL_EPSILON; | 1085 tol = nr * sigma.elem (0) * DBL_EPSILON; |
1196 ComplexMatrix | 1196 ComplexMatrix |
1197 ComplexMatrix::fourier (void) const | 1197 ComplexMatrix::fourier (void) const |
1198 { | 1198 { |
1199 ComplexMatrix retval; | 1199 ComplexMatrix retval; |
1200 | 1200 |
1201 int nr = rows (); | 1201 octave_idx_type nr = rows (); |
1202 int nc = cols (); | 1202 octave_idx_type nc = cols (); |
1203 | 1203 |
1204 int npts, nsamples; | 1204 octave_idx_type npts, nsamples; |
1205 | 1205 |
1206 if (nr == 1 || nc == 1) | 1206 if (nr == 1 || nc == 1) |
1207 { | 1207 { |
1208 npts = nr > nc ? nr : nc; | 1208 npts = nr > nc ? nr : nc; |
1209 nsamples = 1; | 1209 nsamples = 1; |
1212 { | 1212 { |
1213 npts = nr; | 1213 npts = nr; |
1214 nsamples = nc; | 1214 nsamples = nc; |
1215 } | 1215 } |
1216 | 1216 |
1217 int nn = 4*npts+15; | 1217 octave_idx_type nn = 4*npts+15; |
1218 | 1218 |
1219 Array<Complex> wsave (nn); | 1219 Array<Complex> wsave (nn); |
1220 Complex *pwsave = wsave.fortran_vec (); | 1220 Complex *pwsave = wsave.fortran_vec (); |
1221 | 1221 |
1222 retval = *this; | 1222 retval = *this; |
1223 Complex *tmp_data = retval.fortran_vec (); | 1223 Complex *tmp_data = retval.fortran_vec (); |
1224 | 1224 |
1225 F77_FUNC (cffti, CFFTI) (npts, pwsave); | 1225 F77_FUNC (cffti, CFFTI) (npts, pwsave); |
1226 | 1226 |
1227 for (int j = 0; j < nsamples; j++) | 1227 for (octave_idx_type j = 0; j < nsamples; j++) |
1228 { | 1228 { |
1229 OCTAVE_QUIT; | 1229 OCTAVE_QUIT; |
1230 | 1230 |
1231 F77_FUNC (cfftf, CFFTF) (npts, &tmp_data[npts*j], pwsave); | 1231 F77_FUNC (cfftf, CFFTF) (npts, &tmp_data[npts*j], pwsave); |
1232 } | 1232 } |
1237 ComplexMatrix | 1237 ComplexMatrix |
1238 ComplexMatrix::ifourier (void) const | 1238 ComplexMatrix::ifourier (void) const |
1239 { | 1239 { |
1240 ComplexMatrix retval; | 1240 ComplexMatrix retval; |
1241 | 1241 |
1242 int nr = rows (); | 1242 octave_idx_type nr = rows (); |
1243 int nc = cols (); | 1243 octave_idx_type nc = cols (); |
1244 | 1244 |
1245 int npts, nsamples; | 1245 octave_idx_type npts, nsamples; |
1246 | 1246 |
1247 if (nr == 1 || nc == 1) | 1247 if (nr == 1 || nc == 1) |
1248 { | 1248 { |
1249 npts = nr > nc ? nr : nc; | 1249 npts = nr > nc ? nr : nc; |
1250 nsamples = 1; | 1250 nsamples = 1; |
1253 { | 1253 { |
1254 npts = nr; | 1254 npts = nr; |
1255 nsamples = nc; | 1255 nsamples = nc; |
1256 } | 1256 } |
1257 | 1257 |
1258 int nn = 4*npts+15; | 1258 octave_idx_type nn = 4*npts+15; |
1259 | 1259 |
1260 Array<Complex> wsave (nn); | 1260 Array<Complex> wsave (nn); |
1261 Complex *pwsave = wsave.fortran_vec (); | 1261 Complex *pwsave = wsave.fortran_vec (); |
1262 | 1262 |
1263 retval = *this; | 1263 retval = *this; |
1264 Complex *tmp_data = retval.fortran_vec (); | 1264 Complex *tmp_data = retval.fortran_vec (); |
1265 | 1265 |
1266 F77_FUNC (cffti, CFFTI) (npts, pwsave); | 1266 F77_FUNC (cffti, CFFTI) (npts, pwsave); |
1267 | 1267 |
1268 for (int j = 0; j < nsamples; j++) | 1268 for (octave_idx_type j = 0; j < nsamples; j++) |
1269 { | 1269 { |
1270 OCTAVE_QUIT; | 1270 OCTAVE_QUIT; |
1271 | 1271 |
1272 F77_FUNC (cfftb, CFFTB) (npts, &tmp_data[npts*j], pwsave); | 1272 F77_FUNC (cfftb, CFFTB) (npts, &tmp_data[npts*j], pwsave); |
1273 } | 1273 } |
1274 | 1274 |
1275 for (int j = 0; j < npts*nsamples; j++) | 1275 for (octave_idx_type j = 0; j < npts*nsamples; j++) |
1276 tmp_data[j] = tmp_data[j] / static_cast<double> (npts); | 1276 tmp_data[j] = tmp_data[j] / static_cast<double> (npts); |
1277 | 1277 |
1278 return retval; | 1278 return retval; |
1279 } | 1279 } |
1280 | 1280 |
1281 ComplexMatrix | 1281 ComplexMatrix |
1282 ComplexMatrix::fourier2d (void) const | 1282 ComplexMatrix::fourier2d (void) const |
1283 { | 1283 { |
1284 ComplexMatrix retval; | 1284 ComplexMatrix retval; |
1285 | 1285 |
1286 int nr = rows (); | 1286 octave_idx_type nr = rows (); |
1287 int nc = cols (); | 1287 octave_idx_type nc = cols (); |
1288 | 1288 |
1289 int npts, nsamples; | 1289 octave_idx_type npts, nsamples; |
1290 | 1290 |
1291 if (nr == 1 || nc == 1) | 1291 if (nr == 1 || nc == 1) |
1292 { | 1292 { |
1293 npts = nr > nc ? nr : nc; | 1293 npts = nr > nc ? nr : nc; |
1294 nsamples = 1; | 1294 nsamples = 1; |
1297 { | 1297 { |
1298 npts = nr; | 1298 npts = nr; |
1299 nsamples = nc; | 1299 nsamples = nc; |
1300 } | 1300 } |
1301 | 1301 |
1302 int nn = 4*npts+15; | 1302 octave_idx_type nn = 4*npts+15; |
1303 | 1303 |
1304 Array<Complex> wsave (nn); | 1304 Array<Complex> wsave (nn); |
1305 Complex *pwsave = wsave.fortran_vec (); | 1305 Complex *pwsave = wsave.fortran_vec (); |
1306 | 1306 |
1307 retval = *this; | 1307 retval = *this; |
1308 Complex *tmp_data = retval.fortran_vec (); | 1308 Complex *tmp_data = retval.fortran_vec (); |
1309 | 1309 |
1310 F77_FUNC (cffti, CFFTI) (npts, pwsave); | 1310 F77_FUNC (cffti, CFFTI) (npts, pwsave); |
1311 | 1311 |
1312 for (int j = 0; j < nsamples; j++) | 1312 for (octave_idx_type j = 0; j < nsamples; j++) |
1313 { | 1313 { |
1314 OCTAVE_QUIT; | 1314 OCTAVE_QUIT; |
1315 | 1315 |
1316 F77_FUNC (cfftf, CFFTF) (npts, &tmp_data[npts*j], pwsave); | 1316 F77_FUNC (cfftf, CFFTF) (npts, &tmp_data[npts*j], pwsave); |
1317 } | 1317 } |
1326 Array<Complex> tmp (npts); | 1326 Array<Complex> tmp (npts); |
1327 Complex *prow = tmp.fortran_vec (); | 1327 Complex *prow = tmp.fortran_vec (); |
1328 | 1328 |
1329 F77_FUNC (cffti, CFFTI) (npts, pwsave); | 1329 F77_FUNC (cffti, CFFTI) (npts, pwsave); |
1330 | 1330 |
1331 for (int j = 0; j < nsamples; j++) | 1331 for (octave_idx_type j = 0; j < nsamples; j++) |
1332 { | 1332 { |
1333 OCTAVE_QUIT; | 1333 OCTAVE_QUIT; |
1334 | 1334 |
1335 for (int i = 0; i < npts; i++) | 1335 for (octave_idx_type i = 0; i < npts; i++) |
1336 prow[i] = tmp_data[i*nr + j]; | 1336 prow[i] = tmp_data[i*nr + j]; |
1337 | 1337 |
1338 F77_FUNC (cfftf, CFFTF) (npts, prow, pwsave); | 1338 F77_FUNC (cfftf, CFFTF) (npts, prow, pwsave); |
1339 | 1339 |
1340 for (int i = 0; i < npts; i++) | 1340 for (octave_idx_type i = 0; i < npts; i++) |
1341 tmp_data[i*nr + j] = prow[i]; | 1341 tmp_data[i*nr + j] = prow[i]; |
1342 } | 1342 } |
1343 | 1343 |
1344 return retval; | 1344 return retval; |
1345 } | 1345 } |
1347 ComplexMatrix | 1347 ComplexMatrix |
1348 ComplexMatrix::ifourier2d (void) const | 1348 ComplexMatrix::ifourier2d (void) const |
1349 { | 1349 { |
1350 ComplexMatrix retval; | 1350 ComplexMatrix retval; |
1351 | 1351 |
1352 int nr = rows (); | 1352 octave_idx_type nr = rows (); |
1353 int nc = cols (); | 1353 octave_idx_type nc = cols (); |
1354 | 1354 |
1355 int npts, nsamples; | 1355 octave_idx_type npts, nsamples; |
1356 | 1356 |
1357 if (nr == 1 || nc == 1) | 1357 if (nr == 1 || nc == 1) |
1358 { | 1358 { |
1359 npts = nr > nc ? nr : nc; | 1359 npts = nr > nc ? nr : nc; |
1360 nsamples = 1; | 1360 nsamples = 1; |
1363 { | 1363 { |
1364 npts = nr; | 1364 npts = nr; |
1365 nsamples = nc; | 1365 nsamples = nc; |
1366 } | 1366 } |
1367 | 1367 |
1368 int nn = 4*npts+15; | 1368 octave_idx_type nn = 4*npts+15; |
1369 | 1369 |
1370 Array<Complex> wsave (nn); | 1370 Array<Complex> wsave (nn); |
1371 Complex *pwsave = wsave.fortran_vec (); | 1371 Complex *pwsave = wsave.fortran_vec (); |
1372 | 1372 |
1373 retval = *this; | 1373 retval = *this; |
1374 Complex *tmp_data = retval.fortran_vec (); | 1374 Complex *tmp_data = retval.fortran_vec (); |
1375 | 1375 |
1376 F77_FUNC (cffti, CFFTI) (npts, pwsave); | 1376 F77_FUNC (cffti, CFFTI) (npts, pwsave); |
1377 | 1377 |
1378 for (int j = 0; j < nsamples; j++) | 1378 for (octave_idx_type j = 0; j < nsamples; j++) |
1379 { | 1379 { |
1380 OCTAVE_QUIT; | 1380 OCTAVE_QUIT; |
1381 | 1381 |
1382 F77_FUNC (cfftb, CFFTB) (npts, &tmp_data[npts*j], pwsave); | 1382 F77_FUNC (cfftb, CFFTB) (npts, &tmp_data[npts*j], pwsave); |
1383 } | 1383 } |
1384 | 1384 |
1385 for (int j = 0; j < npts*nsamples; j++) | 1385 for (octave_idx_type j = 0; j < npts*nsamples; j++) |
1386 tmp_data[j] = tmp_data[j] / static_cast<double> (npts); | 1386 tmp_data[j] = tmp_data[j] / static_cast<double> (npts); |
1387 | 1387 |
1388 npts = nc; | 1388 npts = nc; |
1389 nsamples = nr; | 1389 nsamples = nr; |
1390 nn = 4*npts+15; | 1390 nn = 4*npts+15; |
1395 Array<Complex> tmp (npts); | 1395 Array<Complex> tmp (npts); |
1396 Complex *prow = tmp.fortran_vec (); | 1396 Complex *prow = tmp.fortran_vec (); |
1397 | 1397 |
1398 F77_FUNC (cffti, CFFTI) (npts, pwsave); | 1398 F77_FUNC (cffti, CFFTI) (npts, pwsave); |
1399 | 1399 |
1400 for (int j = 0; j < nsamples; j++) | 1400 for (octave_idx_type j = 0; j < nsamples; j++) |
1401 { | 1401 { |
1402 OCTAVE_QUIT; | 1402 OCTAVE_QUIT; |
1403 | 1403 |
1404 for (int i = 0; i < npts; i++) | 1404 for (octave_idx_type i = 0; i < npts; i++) |
1405 prow[i] = tmp_data[i*nr + j]; | 1405 prow[i] = tmp_data[i*nr + j]; |
1406 | 1406 |
1407 F77_FUNC (cfftb, CFFTB) (npts, prow, pwsave); | 1407 F77_FUNC (cfftb, CFFTB) (npts, prow, pwsave); |
1408 | 1408 |
1409 for (int i = 0; i < npts; i++) | 1409 for (octave_idx_type i = 0; i < npts; i++) |
1410 tmp_data[i*nr + j] = prow[i] / static_cast<double> (npts); | 1410 tmp_data[i*nr + j] = prow[i] / static_cast<double> (npts); |
1411 } | 1411 } |
1412 | 1412 |
1413 return retval; | 1413 return retval; |
1414 } | 1414 } |
1416 #endif | 1416 #endif |
1417 | 1417 |
1418 ComplexDET | 1418 ComplexDET |
1419 ComplexMatrix::determinant (void) const | 1419 ComplexMatrix::determinant (void) const |
1420 { | 1420 { |
1421 int info; | 1421 octave_idx_type info; |
1422 double rcond; | 1422 double rcond; |
1423 return determinant (info, rcond, 0); | 1423 return determinant (info, rcond, 0); |
1424 } | 1424 } |
1425 | 1425 |
1426 ComplexDET | 1426 ComplexDET |
1427 ComplexMatrix::determinant (int& info) const | 1427 ComplexMatrix::determinant (octave_idx_type& info) const |
1428 { | 1428 { |
1429 double rcond; | 1429 double rcond; |
1430 return determinant (info, rcond, 0); | 1430 return determinant (info, rcond, 0); |
1431 } | 1431 } |
1432 | 1432 |
1433 ComplexDET | 1433 ComplexDET |
1434 ComplexMatrix::determinant (int& info, double& rcond, int calc_cond) const | 1434 ComplexMatrix::determinant (octave_idx_type& info, double& rcond, int calc_cond) const |
1435 { | 1435 { |
1436 ComplexDET retval; | 1436 ComplexDET retval; |
1437 | 1437 |
1438 int nr = rows (); | 1438 octave_idx_type nr = rows (); |
1439 int nc = cols (); | 1439 octave_idx_type nc = cols (); |
1440 | 1440 |
1441 if (nr == 0 || nc == 0) | 1441 if (nr == 0 || nc == 0) |
1442 { | 1442 { |
1443 Complex d[2]; | 1443 Complex d[2]; |
1444 d[0] = 1.0; | 1444 d[0] = 1.0; |
1445 d[1] = 0.0; | 1445 d[1] = 0.0; |
1446 retval = ComplexDET (d); | 1446 retval = ComplexDET (d); |
1447 } | 1447 } |
1448 else | 1448 else |
1449 { | 1449 { |
1450 Array<int> ipvt (nr); | 1450 Array<octave_idx_type> ipvt (nr); |
1451 int *pipvt = ipvt.fortran_vec (); | 1451 octave_idx_type *pipvt = ipvt.fortran_vec (); |
1452 | 1452 |
1453 ComplexMatrix atmp = *this; | 1453 ComplexMatrix atmp = *this; |
1454 Complex *tmp_data = atmp.fortran_vec (); | 1454 Complex *tmp_data = atmp.fortran_vec (); |
1455 | 1455 |
1456 info = 0; | 1456 info = 0; |
1457 | 1457 |
1458 // Calculate the norm of the matrix, for later use. | 1458 // Calculate the norm of the matrix, for later use. |
1459 double anorm = 0; | 1459 double anorm = 0; |
1460 if (calc_cond) | 1460 if (calc_cond) |
1461 anorm = atmp.abs().sum().row(0).max(); | 1461 anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max(); |
1462 | 1462 |
1463 F77_XFCN (zgetrf, ZGETRF, (nr, nc, tmp_data, nr, pipvt, info)); | 1463 F77_XFCN (zgetrf, ZGETRF, (nr, nc, tmp_data, nr, pipvt, info)); |
1464 | 1464 |
1465 if (f77_exception_encountered) | 1465 if (f77_exception_encountered) |
1466 (*current_liboctave_error_handler) ("unrecoverable error in zgetrf"); | 1466 (*current_liboctave_error_handler) ("unrecoverable error in zgetrf"); |
1500 retval = ComplexDET (); | 1500 retval = ComplexDET (); |
1501 } | 1501 } |
1502 else | 1502 else |
1503 { | 1503 { |
1504 Complex d[2] = { 1., 0.}; | 1504 Complex d[2] = { 1., 0.}; |
1505 for (int i=0; i<nc; i++) | 1505 for (octave_idx_type i=0; i<nc; i++) |
1506 { | 1506 { |
1507 if (ipvt(i) != (i+1)) d[0] = -d[0]; | 1507 if (ipvt(i) != (i+1)) d[0] = -d[0]; |
1508 d[0] = d[0] * atmp(i,i); | 1508 d[0] = d[0] * atmp(i,i); |
1509 if (d[0] == 0.) break; | 1509 if (d[0] == 0.) break; |
1510 while (STD_OCTAVE::abs(d[0]) < 1.) | 1510 while (STD_OCTAVE::abs(d[0]) < 1.) |
1528 } | 1528 } |
1529 | 1529 |
1530 ComplexMatrix | 1530 ComplexMatrix |
1531 ComplexMatrix::solve (const Matrix& b) const | 1531 ComplexMatrix::solve (const Matrix& b) const |
1532 { | 1532 { |
1533 int info; | 1533 octave_idx_type info; |
1534 double rcond; | 1534 double rcond; |
1535 return solve (b, info, rcond, 0); | 1535 return solve (b, info, rcond, 0); |
1536 } | 1536 } |
1537 | 1537 |
1538 ComplexMatrix | 1538 ComplexMatrix |
1539 ComplexMatrix::solve (const Matrix& b, int& info) const | 1539 ComplexMatrix::solve (const Matrix& b, octave_idx_type& info) const |
1540 { | 1540 { |
1541 double rcond; | 1541 double rcond; |
1542 return solve (b, info, rcond, 0); | 1542 return solve (b, info, rcond, 0); |
1543 } | 1543 } |
1544 | 1544 |
1545 ComplexMatrix | 1545 ComplexMatrix |
1546 ComplexMatrix::solve (const Matrix& b, int& info, double& rcond) const | 1546 ComplexMatrix::solve (const Matrix& b, octave_idx_type& info, double& rcond) const |
1547 { | 1547 { |
1548 return solve (b, info, rcond, 0); | 1548 return solve (b, info, rcond, 0); |
1549 } | 1549 } |
1550 | 1550 |
1551 ComplexMatrix | 1551 ComplexMatrix |
1552 ComplexMatrix::solve (const Matrix& b, int& info, double& rcond, | 1552 ComplexMatrix::solve (const Matrix& b, octave_idx_type& info, double& rcond, |
1553 solve_singularity_handler sing_handler) const | 1553 solve_singularity_handler sing_handler) const |
1554 { | 1554 { |
1555 ComplexMatrix tmp (b); | 1555 ComplexMatrix tmp (b); |
1556 return solve (tmp, info, rcond, sing_handler); | 1556 return solve (tmp, info, rcond, sing_handler); |
1557 } | 1557 } |
1558 | 1558 |
1559 ComplexMatrix | 1559 ComplexMatrix |
1560 ComplexMatrix::solve (const ComplexMatrix& b) const | 1560 ComplexMatrix::solve (const ComplexMatrix& b) const |
1561 { | 1561 { |
1562 int info; | 1562 octave_idx_type info; |
1563 double rcond; | 1563 double rcond; |
1564 return solve (b, info, rcond, 0); | 1564 return solve (b, info, rcond, 0); |
1565 } | 1565 } |
1566 | 1566 |
1567 ComplexMatrix | 1567 ComplexMatrix |
1568 ComplexMatrix::solve (const ComplexMatrix& b, int& info) const | 1568 ComplexMatrix::solve (const ComplexMatrix& b, octave_idx_type& info) const |
1569 { | 1569 { |
1570 double rcond; | 1570 double rcond; |
1571 return solve (b, info, rcond, 0); | 1571 return solve (b, info, rcond, 0); |
1572 } | 1572 } |
1573 | 1573 |
1574 ComplexMatrix | 1574 ComplexMatrix |
1575 ComplexMatrix::solve (const ComplexMatrix& b, int& info, double& rcond) const | 1575 ComplexMatrix::solve (const ComplexMatrix& b, octave_idx_type& info, double& rcond) const |
1576 { | 1576 { |
1577 return solve (b, info, rcond, 0); | 1577 return solve (b, info, rcond, 0); |
1578 } | 1578 } |
1579 | 1579 |
1580 ComplexMatrix | 1580 ComplexMatrix |
1581 ComplexMatrix::solve (const ComplexMatrix& b, int& info, double& rcond, | 1581 ComplexMatrix::solve (const ComplexMatrix& b, octave_idx_type& info, double& rcond, |
1582 solve_singularity_handler sing_handler) const | 1582 solve_singularity_handler sing_handler) const |
1583 { | 1583 { |
1584 ComplexMatrix retval; | 1584 ComplexMatrix retval; |
1585 | 1585 |
1586 int nr = rows (); | 1586 octave_idx_type nr = rows (); |
1587 int nc = cols (); | 1587 octave_idx_type nc = cols (); |
1588 | 1588 |
1589 if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) | 1589 if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) |
1590 (*current_liboctave_error_handler) | 1590 (*current_liboctave_error_handler) |
1591 ("matrix dimension mismatch in solution of linear equations"); | 1591 ("matrix dimension mismatch in solution of linear equations"); |
1592 else | 1592 else |
1593 { | 1593 { |
1594 info = 0; | 1594 info = 0; |
1595 | 1595 |
1596 Array<int> ipvt (nr); | 1596 Array<octave_idx_type> ipvt (nr); |
1597 int *pipvt = ipvt.fortran_vec (); | 1597 octave_idx_type *pipvt = ipvt.fortran_vec (); |
1598 | 1598 |
1599 ComplexMatrix atmp = *this; | 1599 ComplexMatrix atmp = *this; |
1600 Complex *tmp_data = atmp.fortran_vec (); | 1600 Complex *tmp_data = atmp.fortran_vec (); |
1601 | 1601 |
1602 Array<Complex> z (2 * nc); | 1602 Array<Complex> z (2 * nc); |
1603 Complex *pz = z.fortran_vec (); | 1603 Complex *pz = z.fortran_vec (); |
1604 Array<double> rz (2 * nc); | 1604 Array<double> rz (2 * nc); |
1605 double *prz = rz.fortran_vec (); | 1605 double *prz = rz.fortran_vec (); |
1606 | 1606 |
1607 // Calculate the norm of the matrix, for later use. | 1607 // Calculate the norm of the matrix, for later use. |
1608 double anorm = atmp.abs().sum().row(0).max(); | 1608 double anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max(); |
1609 | 1609 |
1610 F77_XFCN (zgetrf, ZGETRF, (nr, nr, tmp_data, nr, pipvt, info)); | 1610 F77_XFCN (zgetrf, ZGETRF, (nr, nr, tmp_data, nr, pipvt, info)); |
1611 | 1611 |
1612 if (f77_exception_encountered) | 1612 if (f77_exception_encountered) |
1613 (*current_liboctave_error_handler) ("unrecoverable error in zgetrf"); | 1613 (*current_liboctave_error_handler) ("unrecoverable error in zgetrf"); |
1658 else | 1658 else |
1659 { | 1659 { |
1660 retval = b; | 1660 retval = b; |
1661 Complex *result = retval.fortran_vec (); | 1661 Complex *result = retval.fortran_vec (); |
1662 | 1662 |
1663 int b_nc = b.cols (); | 1663 octave_idx_type b_nc = b.cols (); |
1664 | 1664 |
1665 job = 'N'; | 1665 job = 'N'; |
1666 F77_XFCN (zgetrs, ZGETRS, (F77_CONST_CHAR_ARG2 (&job, 1), | 1666 F77_XFCN (zgetrs, ZGETRS, (F77_CONST_CHAR_ARG2 (&job, 1), |
1667 nr, b_nc, tmp_data, nr, | 1667 nr, b_nc, tmp_data, nr, |
1668 pipvt, result, b.rows(), info | 1668 pipvt, result, b.rows(), info |
1680 } | 1680 } |
1681 | 1681 |
1682 ComplexColumnVector | 1682 ComplexColumnVector |
1683 ComplexMatrix::solve (const ColumnVector& b) const | 1683 ComplexMatrix::solve (const ColumnVector& b) const |
1684 { | 1684 { |
1685 int info; | 1685 octave_idx_type info; |
1686 double rcond; | 1686 double rcond; |
1687 return solve (ComplexColumnVector (b), info, rcond, 0); | 1687 return solve (ComplexColumnVector (b), info, rcond, 0); |
1688 } | 1688 } |
1689 | 1689 |
1690 ComplexColumnVector | 1690 ComplexColumnVector |
1691 ComplexMatrix::solve (const ColumnVector& b, int& info) const | 1691 ComplexMatrix::solve (const ColumnVector& b, octave_idx_type& info) const |
1692 { | 1692 { |
1693 double rcond; | 1693 double rcond; |
1694 return solve (ComplexColumnVector (b), info, rcond, 0); | 1694 return solve (ComplexColumnVector (b), info, rcond, 0); |
1695 } | 1695 } |
1696 | 1696 |
1697 ComplexColumnVector | 1697 ComplexColumnVector |
1698 ComplexMatrix::solve (const ColumnVector& b, int& info, double& rcond) const | 1698 ComplexMatrix::solve (const ColumnVector& b, octave_idx_type& info, double& rcond) const |
1699 { | 1699 { |
1700 return solve (ComplexColumnVector (b), info, rcond, 0); | 1700 return solve (ComplexColumnVector (b), info, rcond, 0); |
1701 } | 1701 } |
1702 | 1702 |
1703 ComplexColumnVector | 1703 ComplexColumnVector |
1704 ComplexMatrix::solve (const ColumnVector& b, int& info, double& rcond, | 1704 ComplexMatrix::solve (const ColumnVector& b, octave_idx_type& info, double& rcond, |
1705 solve_singularity_handler sing_handler) const | 1705 solve_singularity_handler sing_handler) const |
1706 { | 1706 { |
1707 return solve (ComplexColumnVector (b), info, rcond, sing_handler); | 1707 return solve (ComplexColumnVector (b), info, rcond, sing_handler); |
1708 } | 1708 } |
1709 | 1709 |
1710 ComplexColumnVector | 1710 ComplexColumnVector |
1711 ComplexMatrix::solve (const ComplexColumnVector& b) const | 1711 ComplexMatrix::solve (const ComplexColumnVector& b) const |
1712 { | 1712 { |
1713 int info; | 1713 octave_idx_type info; |
1714 double rcond; | 1714 double rcond; |
1715 return solve (b, info, rcond, 0); | 1715 return solve (b, info, rcond, 0); |
1716 } | 1716 } |
1717 | 1717 |
1718 ComplexColumnVector | 1718 ComplexColumnVector |
1719 ComplexMatrix::solve (const ComplexColumnVector& b, int& info) const | 1719 ComplexMatrix::solve (const ComplexColumnVector& b, octave_idx_type& info) const |
1720 { | 1720 { |
1721 double rcond; | 1721 double rcond; |
1722 return solve (b, info, rcond, 0); | 1722 return solve (b, info, rcond, 0); |
1723 } | 1723 } |
1724 | 1724 |
1725 ComplexColumnVector | 1725 ComplexColumnVector |
1726 ComplexMatrix::solve (const ComplexColumnVector& b, int& info, | 1726 ComplexMatrix::solve (const ComplexColumnVector& b, octave_idx_type& info, |
1727 double& rcond) const | 1727 double& rcond) const |
1728 { | 1728 { |
1729 return solve (b, info, rcond, 0); | 1729 return solve (b, info, rcond, 0); |
1730 } | 1730 } |
1731 | 1731 |
1732 ComplexColumnVector | 1732 ComplexColumnVector |
1733 ComplexMatrix::solve (const ComplexColumnVector& b, int& info, | 1733 ComplexMatrix::solve (const ComplexColumnVector& b, octave_idx_type& info, |
1734 double& rcond, | 1734 double& rcond, |
1735 solve_singularity_handler sing_handler) const | 1735 solve_singularity_handler sing_handler) const |
1736 { | 1736 { |
1737 ComplexColumnVector retval; | 1737 ComplexColumnVector retval; |
1738 | 1738 |
1739 int nr = rows (); | 1739 octave_idx_type nr = rows (); |
1740 int nc = cols (); | 1740 octave_idx_type nc = cols (); |
1741 | 1741 |
1742 if (nr == 0 || nc == 0 || nr != nc || nr != b.length ()) | 1742 if (nr == 0 || nc == 0 || nr != nc || nr != b.length ()) |
1743 (*current_liboctave_error_handler) | 1743 (*current_liboctave_error_handler) |
1744 ("matrix dimension mismatch in solution of linear equations"); | 1744 ("matrix dimension mismatch in solution of linear equations"); |
1745 else | 1745 else |
1746 { | 1746 { |
1747 info = 0; | 1747 info = 0; |
1748 | 1748 |
1749 Array<int> ipvt (nr); | 1749 Array<octave_idx_type> ipvt (nr); |
1750 int *pipvt = ipvt.fortran_vec (); | 1750 octave_idx_type *pipvt = ipvt.fortran_vec (); |
1751 | 1751 |
1752 ComplexMatrix atmp = *this; | 1752 ComplexMatrix atmp = *this; |
1753 Complex *tmp_data = atmp.fortran_vec (); | 1753 Complex *tmp_data = atmp.fortran_vec (); |
1754 | 1754 |
1755 Array<Complex> z (2 * nc); | 1755 Array<Complex> z (2 * nc); |
1756 Complex *pz = z.fortran_vec (); | 1756 Complex *pz = z.fortran_vec (); |
1757 Array<double> rz (2 * nc); | 1757 Array<double> rz (2 * nc); |
1758 double *prz = rz.fortran_vec (); | 1758 double *prz = rz.fortran_vec (); |
1759 | 1759 |
1760 // Calculate the norm of the matrix, for later use. | 1760 // Calculate the norm of the matrix, for later use. |
1761 double anorm = atmp.abs().sum().row(0).max(); | 1761 double anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max(); |
1762 | 1762 |
1763 F77_XFCN (zgetrf, ZGETRF, (nr, nr, tmp_data, nr, pipvt, info)); | 1763 F77_XFCN (zgetrf, ZGETRF, (nr, nr, tmp_data, nr, pipvt, info)); |
1764 | 1764 |
1765 if (f77_exception_encountered) | 1765 if (f77_exception_encountered) |
1766 (*current_liboctave_error_handler) ("unrecoverable error in zgetrf"); | 1766 (*current_liboctave_error_handler) ("unrecoverable error in zgetrf"); |
1831 } | 1831 } |
1832 | 1832 |
1833 ComplexMatrix | 1833 ComplexMatrix |
1834 ComplexMatrix::lssolve (const Matrix& b) const | 1834 ComplexMatrix::lssolve (const Matrix& b) const |
1835 { | 1835 { |
1836 int info; | 1836 octave_idx_type info; |
1837 int rank; | 1837 octave_idx_type rank; |
1838 return lssolve (ComplexMatrix (b), info, rank); | 1838 return lssolve (ComplexMatrix (b), info, rank); |
1839 } | 1839 } |
1840 | 1840 |
1841 ComplexMatrix | 1841 ComplexMatrix |
1842 ComplexMatrix::lssolve (const Matrix& b, int& info) const | 1842 ComplexMatrix::lssolve (const Matrix& b, octave_idx_type& info) const |
1843 { | 1843 { |
1844 int rank; | 1844 octave_idx_type rank; |
1845 return lssolve (ComplexMatrix (b), info, rank); | 1845 return lssolve (ComplexMatrix (b), info, rank); |
1846 } | 1846 } |
1847 | 1847 |
1848 ComplexMatrix | 1848 ComplexMatrix |
1849 ComplexMatrix::lssolve (const Matrix& b, int& info, int& rank) const | 1849 ComplexMatrix::lssolve (const Matrix& b, octave_idx_type& info, octave_idx_type& rank) const |
1850 { | 1850 { |
1851 return lssolve (ComplexMatrix (b), info, rank); | 1851 return lssolve (ComplexMatrix (b), info, rank); |
1852 } | 1852 } |
1853 | 1853 |
1854 ComplexMatrix | 1854 ComplexMatrix |
1855 ComplexMatrix::lssolve (const ComplexMatrix& b) const | 1855 ComplexMatrix::lssolve (const ComplexMatrix& b) const |
1856 { | 1856 { |
1857 int info; | 1857 octave_idx_type info; |
1858 int rank; | 1858 octave_idx_type rank; |
1859 return lssolve (b, info, rank); | 1859 return lssolve (b, info, rank); |
1860 } | 1860 } |
1861 | 1861 |
1862 ComplexMatrix | 1862 ComplexMatrix |
1863 ComplexMatrix::lssolve (const ComplexMatrix& b, int& info) const | 1863 ComplexMatrix::lssolve (const ComplexMatrix& b, octave_idx_type& info) const |
1864 { | 1864 { |
1865 int rank; | 1865 octave_idx_type rank; |
1866 return lssolve (b, info, rank); | 1866 return lssolve (b, info, rank); |
1867 } | 1867 } |
1868 | 1868 |
1869 ComplexMatrix | 1869 ComplexMatrix |
1870 ComplexMatrix::lssolve (const ComplexMatrix& b, int& info, int& rank) const | 1870 ComplexMatrix::lssolve (const ComplexMatrix& b, octave_idx_type& info, octave_idx_type& rank) const |
1871 { | 1871 { |
1872 ComplexMatrix retval; | 1872 ComplexMatrix retval; |
1873 | 1873 |
1874 int nrhs = b.cols (); | 1874 octave_idx_type nrhs = b.cols (); |
1875 | 1875 |
1876 int m = rows (); | 1876 octave_idx_type m = rows (); |
1877 int n = cols (); | 1877 octave_idx_type n = cols (); |
1878 | 1878 |
1879 if (m == 0 || n == 0 || m != b.rows ()) | 1879 if (m == 0 || n == 0 || m != b.rows ()) |
1880 (*current_liboctave_error_handler) | 1880 (*current_liboctave_error_handler) |
1881 ("matrix dimension mismatch solution of linear equations"); | 1881 ("matrix dimension mismatch solution of linear equations"); |
1882 else | 1882 else |
1883 { | 1883 { |
1884 ComplexMatrix atmp = *this; | 1884 ComplexMatrix atmp = *this; |
1885 Complex *tmp_data = atmp.fortran_vec (); | 1885 Complex *tmp_data = atmp.fortran_vec (); |
1886 | 1886 |
1887 int nrr = m > n ? m : n; | 1887 octave_idx_type nrr = m > n ? m : n; |
1888 ComplexMatrix result (nrr, nrhs); | 1888 ComplexMatrix result (nrr, nrhs); |
1889 | 1889 |
1890 for (int j = 0; j < nrhs; j++) | 1890 for (octave_idx_type j = 0; j < nrhs; j++) |
1891 for (int i = 0; i < m; i++) | 1891 for (octave_idx_type i = 0; i < m; i++) |
1892 result.elem (i, j) = b.elem (i, j); | 1892 result.elem (i, j) = b.elem (i, j); |
1893 | 1893 |
1894 Complex *presult = result.fortran_vec (); | 1894 Complex *presult = result.fortran_vec (); |
1895 | 1895 |
1896 int len_s = m < n ? m : n; | 1896 octave_idx_type len_s = m < n ? m : n; |
1897 Array<double> s (len_s); | 1897 Array<double> s (len_s); |
1898 double *ps = s.fortran_vec (); | 1898 double *ps = s.fortran_vec (); |
1899 | 1899 |
1900 double rcond = -1.0; | 1900 double rcond = -1.0; |
1901 | 1901 |
1902 int lrwork = (5 * (m < n ? m : n)) - 4; | 1902 octave_idx_type lrwork = (5 * (m < n ? m : n)) - 4; |
1903 lrwork = lrwork > 1 ? lrwork : 1; | 1903 lrwork = lrwork > 1 ? lrwork : 1; |
1904 Array<double> rwork (lrwork); | 1904 Array<double> rwork (lrwork); |
1905 double *prwork = rwork.fortran_vec (); | 1905 double *prwork = rwork.fortran_vec (); |
1906 | 1906 |
1907 // Ask ZGELSS what the dimension of WORK should be. | 1907 // Ask ZGELSS what the dimension of WORK should be. |
1908 | 1908 |
1909 int lwork = -1; | 1909 octave_idx_type lwork = -1; |
1910 | |
1911 Array<Complex> work (1); | |
1912 | |
1913 F77_XFCN (zgelss, ZGELSS, (m, n, nrhs, tmp_data, m, presult, | |
1914 nrr, ps, rcond, rank, | |
1915 work.fortran_vec (), lwork, prwork, | |
1916 info)); | |
1917 | |
1918 if (f77_exception_encountered) | |
1919 (*current_liboctave_error_handler) ("unrecoverable error in zgelss"); | |
1920 else | |
1921 { | |
1922 lwork = static_cast<octave_idx_type> (STD_OCTAVE::real (work(0))); | |
1923 work.resize (lwork); | |
1924 | |
1925 F77_XFCN (zgelss, ZGELSS, (m, n, nrhs, tmp_data, m, presult, | |
1926 nrr, ps, rcond, rank, | |
1927 work.fortran_vec (), lwork, | |
1928 prwork, info)); | |
1929 | |
1930 if (f77_exception_encountered) | |
1931 (*current_liboctave_error_handler) | |
1932 ("unrecoverable error in zgelss"); | |
1933 else | |
1934 { | |
1935 retval.resize (n, nrhs); | |
1936 for (octave_idx_type j = 0; j < nrhs; j++) | |
1937 for (octave_idx_type i = 0; i < n; i++) | |
1938 retval.elem (i, j) = result.elem (i, j); | |
1939 } | |
1940 } | |
1941 } | |
1942 | |
1943 return retval; | |
1944 } | |
1945 | |
1946 ComplexColumnVector | |
1947 ComplexMatrix::lssolve (const ColumnVector& b) const | |
1948 { | |
1949 octave_idx_type info; | |
1950 octave_idx_type rank; | |
1951 return lssolve (ComplexColumnVector (b), info, rank); | |
1952 } | |
1953 | |
1954 ComplexColumnVector | |
1955 ComplexMatrix::lssolve (const ColumnVector& b, octave_idx_type& info) const | |
1956 { | |
1957 octave_idx_type rank; | |
1958 return lssolve (ComplexColumnVector (b), info, rank); | |
1959 } | |
1960 | |
1961 ComplexColumnVector | |
1962 ComplexMatrix::lssolve (const ColumnVector& b, octave_idx_type& info, octave_idx_type& rank) const | |
1963 { | |
1964 return lssolve (ComplexColumnVector (b), info, rank); | |
1965 } | |
1966 | |
1967 ComplexColumnVector | |
1968 ComplexMatrix::lssolve (const ComplexColumnVector& b) const | |
1969 { | |
1970 octave_idx_type info; | |
1971 octave_idx_type rank; | |
1972 return lssolve (b, info, rank); | |
1973 } | |
1974 | |
1975 ComplexColumnVector | |
1976 ComplexMatrix::lssolve (const ComplexColumnVector& b, octave_idx_type& info) const | |
1977 { | |
1978 octave_idx_type rank; | |
1979 return lssolve (b, info, rank); | |
1980 } | |
1981 | |
1982 ComplexColumnVector | |
1983 ComplexMatrix::lssolve (const ComplexColumnVector& b, octave_idx_type& info, | |
1984 octave_idx_type& rank) const | |
1985 { | |
1986 ComplexColumnVector retval; | |
1987 | |
1988 octave_idx_type nrhs = 1; | |
1989 | |
1990 octave_idx_type m = rows (); | |
1991 octave_idx_type n = cols (); | |
1992 | |
1993 if (m == 0 || n == 0 || m != b.length ()) | |
1994 (*current_liboctave_error_handler) | |
1995 ("matrix dimension mismatch solution of least squares problem"); | |
1996 else | |
1997 { | |
1998 ComplexMatrix atmp = *this; | |
1999 Complex *tmp_data = atmp.fortran_vec (); | |
2000 | |
2001 octave_idx_type nrr = m > n ? m : n; | |
2002 ComplexColumnVector result (nrr); | |
2003 | |
2004 for (octave_idx_type i = 0; i < m; i++) | |
2005 result.elem (i) = b.elem (i); | |
2006 | |
2007 Complex *presult = result.fortran_vec (); | |
2008 | |
2009 octave_idx_type len_s = m < n ? m : n; | |
2010 Array<double> s (len_s); | |
2011 double *ps = s.fortran_vec (); | |
2012 | |
2013 double rcond = -1.0; | |
2014 | |
2015 octave_idx_type lrwork = (5 * (m < n ? m : n)) - 4; | |
2016 lrwork = lrwork > 1 ? lrwork : 1; | |
2017 Array<double> rwork (lrwork); | |
2018 double *prwork = rwork.fortran_vec (); | |
2019 | |
2020 // Ask ZGELSS what the dimension of WORK should be. | |
2021 | |
2022 octave_idx_type lwork = -1; | |
1910 | 2023 |
1911 Array<Complex> work (1); | 2024 Array<Complex> work (1); |
1912 | 2025 |
1913 F77_XFCN (zgelss, ZGELSS, (m, n, nrhs, tmp_data, m, presult, | 2026 F77_XFCN (zgelss, ZGELSS, (m, n, nrhs, tmp_data, m, presult, |
1914 nrr, ps, rcond, rank, | 2027 nrr, ps, rcond, rank, |
1930 if (f77_exception_encountered) | 2043 if (f77_exception_encountered) |
1931 (*current_liboctave_error_handler) | 2044 (*current_liboctave_error_handler) |
1932 ("unrecoverable error in zgelss"); | 2045 ("unrecoverable error in zgelss"); |
1933 else | 2046 else |
1934 { | 2047 { |
1935 retval.resize (n, nrhs); | |
1936 for (int j = 0; j < nrhs; j++) | |
1937 for (int i = 0; i < n; i++) | |
1938 retval.elem (i, j) = result.elem (i, j); | |
1939 } | |
1940 } | |
1941 } | |
1942 | |
1943 return retval; | |
1944 } | |
1945 | |
1946 ComplexColumnVector | |
1947 ComplexMatrix::lssolve (const ColumnVector& b) const | |
1948 { | |
1949 int info; | |
1950 int rank; | |
1951 return lssolve (ComplexColumnVector (b), info, rank); | |
1952 } | |
1953 | |
1954 ComplexColumnVector | |
1955 ComplexMatrix::lssolve (const ColumnVector& b, int& info) const | |
1956 { | |
1957 int rank; | |
1958 return lssolve (ComplexColumnVector (b), info, rank); | |
1959 } | |
1960 | |
1961 ComplexColumnVector | |
1962 ComplexMatrix::lssolve (const ColumnVector& b, int& info, int& rank) const | |
1963 { | |
1964 return lssolve (ComplexColumnVector (b), info, rank); | |
1965 } | |
1966 | |
1967 ComplexColumnVector | |
1968 ComplexMatrix::lssolve (const ComplexColumnVector& b) const | |
1969 { | |
1970 int info; | |
1971 int rank; | |
1972 return lssolve (b, info, rank); | |
1973 } | |
1974 | |
1975 ComplexColumnVector | |
1976 ComplexMatrix::lssolve (const ComplexColumnVector& b, int& info) const | |
1977 { | |
1978 int rank; | |
1979 return lssolve (b, info, rank); | |
1980 } | |
1981 | |
1982 ComplexColumnVector | |
1983 ComplexMatrix::lssolve (const ComplexColumnVector& b, int& info, | |
1984 int& rank) const | |
1985 { | |
1986 ComplexColumnVector retval; | |
1987 | |
1988 int nrhs = 1; | |
1989 | |
1990 int m = rows (); | |
1991 int n = cols (); | |
1992 | |
1993 if (m == 0 || n == 0 || m != b.length ()) | |
1994 (*current_liboctave_error_handler) | |
1995 ("matrix dimension mismatch solution of least squares problem"); | |
1996 else | |
1997 { | |
1998 ComplexMatrix atmp = *this; | |
1999 Complex *tmp_data = atmp.fortran_vec (); | |
2000 | |
2001 int nrr = m > n ? m : n; | |
2002 ComplexColumnVector result (nrr); | |
2003 | |
2004 for (int i = 0; i < m; i++) | |
2005 result.elem (i) = b.elem (i); | |
2006 | |
2007 Complex *presult = result.fortran_vec (); | |
2008 | |
2009 int len_s = m < n ? m : n; | |
2010 Array<double> s (len_s); | |
2011 double *ps = s.fortran_vec (); | |
2012 | |
2013 double rcond = -1.0; | |
2014 | |
2015 int lrwork = (5 * (m < n ? m : n)) - 4; | |
2016 lrwork = lrwork > 1 ? lrwork : 1; | |
2017 Array<double> rwork (lrwork); | |
2018 double *prwork = rwork.fortran_vec (); | |
2019 | |
2020 // Ask ZGELSS what the dimension of WORK should be. | |
2021 | |
2022 int lwork = -1; | |
2023 | |
2024 Array<Complex> work (1); | |
2025 | |
2026 F77_XFCN (zgelss, ZGELSS, (m, n, nrhs, tmp_data, m, presult, | |
2027 nrr, ps, rcond, rank, | |
2028 work.fortran_vec (), lwork, prwork, | |
2029 info)); | |
2030 | |
2031 if (f77_exception_encountered) | |
2032 (*current_liboctave_error_handler) ("unrecoverable error in zgelss"); | |
2033 else | |
2034 { | |
2035 lwork = static_cast<int> (STD_OCTAVE::real (work(0))); | |
2036 work.resize (lwork); | |
2037 | |
2038 F77_XFCN (zgelss, ZGELSS, (m, n, nrhs, tmp_data, m, presult, | |
2039 nrr, ps, rcond, rank, | |
2040 work.fortran_vec (), lwork, | |
2041 prwork, info)); | |
2042 | |
2043 if (f77_exception_encountered) | |
2044 (*current_liboctave_error_handler) | |
2045 ("unrecoverable error in zgelss"); | |
2046 else | |
2047 { | |
2048 retval.resize (n); | 2048 retval.resize (n); |
2049 for (int i = 0; i < n; i++) | 2049 for (octave_idx_type i = 0; i < n; i++) |
2050 retval.elem (i) = result.elem (i); | 2050 retval.elem (i) = result.elem (i); |
2051 } | 2051 } |
2052 } | 2052 } |
2053 } | 2053 } |
2054 | 2054 |
2074 { | 2074 { |
2075 ComplexMatrix retval; | 2075 ComplexMatrix retval; |
2076 | 2076 |
2077 ComplexMatrix m = *this; | 2077 ComplexMatrix m = *this; |
2078 | 2078 |
2079 int nc = columns (); | 2079 octave_idx_type nc = columns (); |
2080 | 2080 |
2081 // Preconditioning step 1: trace normalization to reduce dynamic | 2081 // Preconditioning step 1: trace normalization to reduce dynamic |
2082 // range of poles, but avoid making stable eigenvalues unstable. | 2082 // range of poles, but avoid making stable eigenvalues unstable. |
2083 | 2083 |
2084 // trace shift value | 2084 // trace shift value |
2085 Complex trshift = 0.0; | 2085 Complex trshift = 0.0; |
2086 | 2086 |
2087 for (int i = 0; i < nc; i++) | 2087 for (octave_idx_type i = 0; i < nc; i++) |
2088 trshift += m.elem (i, i); | 2088 trshift += m.elem (i, i); |
2089 | 2089 |
2090 trshift /= nc; | 2090 trshift /= nc; |
2091 | 2091 |
2092 if (trshift.real () < 0.0) | 2092 if (trshift.real () < 0.0) |
2093 trshift = trshift.imag (); | 2093 trshift = trshift.imag (); |
2094 | 2094 |
2095 for (int i = 0; i < nc; i++) | 2095 for (octave_idx_type i = 0; i < nc; i++) |
2096 m.elem (i, i) -= trshift; | 2096 m.elem (i, i) -= trshift; |
2097 | 2097 |
2098 // Preconditioning step 2: eigenvalue balancing. | 2098 // Preconditioning step 2: eigenvalue balancing. |
2099 // code follows development in AEPBAL | 2099 // code follows development in AEPBAL |
2100 | 2100 |
2101 Complex *mp = m.fortran_vec (); | 2101 Complex *mp = m.fortran_vec (); |
2102 | 2102 |
2103 int info, ilo, ihi,ilos,ihis; | 2103 octave_idx_type info, ilo, ihi,ilos,ihis; |
2104 Array<double> dpermute (nc); | 2104 Array<double> dpermute (nc); |
2105 Array<double> dscale (nc); | 2105 Array<double> dscale (nc); |
2106 | 2106 |
2107 // XXX FIXME XXX -- should pass job as a parameter in expm | 2107 // XXX FIXME XXX -- should pass job as a parameter in expm |
2108 | 2108 |
2157 sqpow = 0; | 2157 sqpow = 0; |
2158 | 2158 |
2159 if (sqpow > 0) | 2159 if (sqpow > 0) |
2160 { | 2160 { |
2161 double scale_factor = 1.0; | 2161 double scale_factor = 1.0; |
2162 for (int i = 0; i < sqpow; i++) | 2162 for (octave_idx_type i = 0; i < sqpow; i++) |
2163 scale_factor *= 2.0; | 2163 scale_factor *= 2.0; |
2164 | 2164 |
2165 m = m / scale_factor; | 2165 m = m / scale_factor; |
2166 } | 2166 } |
2167 | 2167 |
2171 ComplexMatrix dpp = npp; | 2171 ComplexMatrix dpp = npp; |
2172 | 2172 |
2173 // Now powers a^8 ... a^1. | 2173 // Now powers a^8 ... a^1. |
2174 | 2174 |
2175 int minus_one_j = -1; | 2175 int minus_one_j = -1; |
2176 for (int j = 7; j >= 0; j--) | 2176 for (octave_idx_type j = 7; j >= 0; j--) |
2177 { | 2177 { |
2178 npp = m * npp + m * padec[j]; | 2178 npp = m * npp + m * padec[j]; |
2179 dpp = m * dpp + m * (minus_one_j * padec[j]); | 2179 dpp = m * dpp + m * (minus_one_j * padec[j]); |
2180 minus_one_j *= -1; | 2180 minus_one_j *= -1; |
2181 } | 2181 } |
2182 | 2182 |
2183 // Zero power. | 2183 // Zero power. |
2184 | 2184 |
2185 dpp = -dpp; | 2185 dpp = -dpp; |
2186 for (int j = 0; j < nc; j++) | 2186 for (octave_idx_type j = 0; j < nc; j++) |
2187 { | 2187 { |
2188 npp.elem (j, j) += 1.0; | 2188 npp.elem (j, j) += 1.0; |
2189 dpp.elem (j, j) += 1.0; | 2189 dpp.elem (j, j) += 1.0; |
2190 } | 2190 } |
2191 | 2191 |
2203 | 2203 |
2204 // Reverse preconditioning step 2: inverse balancing. | 2204 // Reverse preconditioning step 2: inverse balancing. |
2205 // Done in two steps: inverse scaling, then inverse permutation | 2205 // Done in two steps: inverse scaling, then inverse permutation |
2206 | 2206 |
2207 // inverse scaling (diagonal transformation) | 2207 // inverse scaling (diagonal transformation) |
2208 for (int i = 0; i < nc; i++) | 2208 for (octave_idx_type i = 0; i < nc; i++) |
2209 for (int j = 0; j < nc; j++) | 2209 for (octave_idx_type j = 0; j < nc; j++) |
2210 retval(i,j) *= dscale(i) / dscale(j); | 2210 retval(i,j) *= dscale(i) / dscale(j); |
2211 | 2211 |
2212 OCTAVE_QUIT; | 2212 OCTAVE_QUIT; |
2213 | 2213 |
2214 // construct balancing permutation vector | 2214 // construct balancing permutation vector |
2215 Array<int> iperm (nc); | 2215 Array<int> iperm (nc); |
2216 for (int i = 0; i < nc; i++) | 2216 for (octave_idx_type i = 0; i < nc; i++) |
2217 iperm(i) = i; // initialize to identity permutation | 2217 iperm(i) = i; // initialize to identity permutation |
2218 | 2218 |
2219 // leading permutations in forward order | 2219 // leading permutations in forward order |
2220 for (int i = 0; i < (ilo-1); i++) | 2220 for (octave_idx_type i = 0; i < (ilo-1); i++) |
2221 { | 2221 { |
2222 int swapidx = static_cast<int> (dpermute(i)) - 1; | 2222 octave_idx_type swapidx = static_cast<int> (dpermute(i)) - 1; |
2223 int tmp = iperm(i); | 2223 octave_idx_type tmp = iperm(i); |
2224 iperm(i) = iperm(swapidx); | 2224 iperm(i) = iperm(swapidx); |
2225 iperm(swapidx) = tmp; | 2225 iperm(swapidx) = tmp; |
2226 } | 2226 } |
2227 | 2227 |
2228 // trailing permutations must be done in reverse order | 2228 // trailing permutations must be done in reverse order |
2229 for (int i = nc - 1; i >= ihi; i--) | 2229 for (octave_idx_type i = nc - 1; i >= ihi; i--) |
2230 { | 2230 { |
2231 int swapidx = static_cast<int> (dpermute(i)) - 1; | 2231 octave_idx_type swapidx = static_cast<int> (dpermute(i)) - 1; |
2232 int tmp = iperm(i); | 2232 octave_idx_type tmp = iperm(i); |
2233 iperm(i) = iperm(swapidx); | 2233 iperm(i) = iperm(swapidx); |
2234 iperm(swapidx) = tmp; | 2234 iperm(swapidx) = tmp; |
2235 } | 2235 } |
2236 | 2236 |
2237 // construct inverse balancing permutation vector | 2237 // construct inverse balancing permutation vector |
2238 Array<int> invpvec (nc); | 2238 Array<int> invpvec (nc); |
2239 for (int i = 0; i < nc; i++) | 2239 for (octave_idx_type i = 0; i < nc; i++) |
2240 invpvec(iperm(i)) = i; // Thanks to R. A. Lippert for this method | 2240 invpvec(iperm(i)) = i; // Thanks to R. A. Lippert for this method |
2241 | 2241 |
2242 OCTAVE_QUIT; | 2242 OCTAVE_QUIT; |
2243 | 2243 |
2244 ComplexMatrix tmpMat = retval; | 2244 ComplexMatrix tmpMat = retval; |
2245 for (int i = 0; i < nc; i++) | 2245 for (octave_idx_type i = 0; i < nc; i++) |
2246 for (int j = 0; j < nc; j++) | 2246 for (octave_idx_type j = 0; j < nc; j++) |
2247 retval(i,j) = tmpMat(invpvec(i),invpvec(j)); | 2247 retval(i,j) = tmpMat(invpvec(i),invpvec(j)); |
2248 | 2248 |
2249 // Reverse preconditioning step 1: fix trace normalization. | 2249 // Reverse preconditioning step 1: fix trace normalization. |
2250 | 2250 |
2251 return exp (trshift) * retval; | 2251 return exp (trshift) * retval; |
2270 ComplexMatrix | 2270 ComplexMatrix |
2271 operator * (const ComplexColumnVector& v, const ComplexRowVector& a) | 2271 operator * (const ComplexColumnVector& v, const ComplexRowVector& a) |
2272 { | 2272 { |
2273 ComplexMatrix retval; | 2273 ComplexMatrix retval; |
2274 | 2274 |
2275 int len = v.length (); | 2275 octave_idx_type len = v.length (); |
2276 | 2276 |
2277 if (len != 0) | 2277 if (len != 0) |
2278 { | 2278 { |
2279 int a_len = a.length (); | 2279 octave_idx_type a_len = a.length (); |
2280 | 2280 |
2281 retval.resize (len, a_len); | 2281 retval.resize (len, a_len); |
2282 Complex *c = retval.fortran_vec (); | 2282 Complex *c = retval.fortran_vec (); |
2283 | 2283 |
2284 F77_XFCN (zgemm, ZGEMM, (F77_CONST_CHAR_ARG2 ("N", 1), | 2284 F77_XFCN (zgemm, ZGEMM, (F77_CONST_CHAR_ARG2 ("N", 1), |
2299 // matrix by diagonal matrix -> matrix operations | 2299 // matrix by diagonal matrix -> matrix operations |
2300 | 2300 |
2301 ComplexMatrix& | 2301 ComplexMatrix& |
2302 ComplexMatrix::operator += (const DiagMatrix& a) | 2302 ComplexMatrix::operator += (const DiagMatrix& a) |
2303 { | 2303 { |
2304 int nr = rows (); | 2304 octave_idx_type nr = rows (); |
2305 int nc = cols (); | 2305 octave_idx_type nc = cols (); |
2306 | 2306 |
2307 int a_nr = rows (); | 2307 octave_idx_type a_nr = rows (); |
2308 int a_nc = cols (); | 2308 octave_idx_type a_nc = cols (); |
2309 | 2309 |
2310 if (nr != a_nr || nc != a_nc) | 2310 if (nr != a_nr || nc != a_nc) |
2311 { | 2311 { |
2312 gripe_nonconformant ("operator +=", nr, nc, a_nr, a_nc); | 2312 gripe_nonconformant ("operator +=", nr, nc, a_nr, a_nc); |
2313 return *this; | 2313 return *this; |
2314 } | 2314 } |
2315 | 2315 |
2316 for (int i = 0; i < a.length (); i++) | 2316 for (octave_idx_type i = 0; i < a.length (); i++) |
2317 elem (i, i) += a.elem (i, i); | 2317 elem (i, i) += a.elem (i, i); |
2318 | 2318 |
2319 return *this; | 2319 return *this; |
2320 } | 2320 } |
2321 | 2321 |
2322 ComplexMatrix& | 2322 ComplexMatrix& |
2323 ComplexMatrix::operator -= (const DiagMatrix& a) | 2323 ComplexMatrix::operator -= (const DiagMatrix& a) |
2324 { | 2324 { |
2325 int nr = rows (); | 2325 octave_idx_type nr = rows (); |
2326 int nc = cols (); | 2326 octave_idx_type nc = cols (); |
2327 | 2327 |
2328 int a_nr = rows (); | 2328 octave_idx_type a_nr = rows (); |
2329 int a_nc = cols (); | 2329 octave_idx_type a_nc = cols (); |
2330 | 2330 |
2331 if (nr != a_nr || nc != a_nc) | 2331 if (nr != a_nr || nc != a_nc) |
2332 { | 2332 { |
2333 gripe_nonconformant ("operator -=", nr, nc, a_nr, a_nc); | 2333 gripe_nonconformant ("operator -=", nr, nc, a_nr, a_nc); |
2334 return *this; | 2334 return *this; |
2335 } | 2335 } |
2336 | 2336 |
2337 for (int i = 0; i < a.length (); i++) | 2337 for (octave_idx_type i = 0; i < a.length (); i++) |
2338 elem (i, i) -= a.elem (i, i); | 2338 elem (i, i) -= a.elem (i, i); |
2339 | 2339 |
2340 return *this; | 2340 return *this; |
2341 } | 2341 } |
2342 | 2342 |
2343 ComplexMatrix& | 2343 ComplexMatrix& |
2344 ComplexMatrix::operator += (const ComplexDiagMatrix& a) | 2344 ComplexMatrix::operator += (const ComplexDiagMatrix& a) |
2345 { | 2345 { |
2346 int nr = rows (); | 2346 octave_idx_type nr = rows (); |
2347 int nc = cols (); | 2347 octave_idx_type nc = cols (); |
2348 | 2348 |
2349 int a_nr = rows (); | 2349 octave_idx_type a_nr = rows (); |
2350 int a_nc = cols (); | 2350 octave_idx_type a_nc = cols (); |
2351 | 2351 |
2352 if (nr != a_nr || nc != a_nc) | 2352 if (nr != a_nr || nc != a_nc) |
2353 { | 2353 { |
2354 gripe_nonconformant ("operator +=", nr, nc, a_nr, a_nc); | 2354 gripe_nonconformant ("operator +=", nr, nc, a_nr, a_nc); |
2355 return *this; | 2355 return *this; |
2356 } | 2356 } |
2357 | 2357 |
2358 for (int i = 0; i < a.length (); i++) | 2358 for (octave_idx_type i = 0; i < a.length (); i++) |
2359 elem (i, i) += a.elem (i, i); | 2359 elem (i, i) += a.elem (i, i); |
2360 | 2360 |
2361 return *this; | 2361 return *this; |
2362 } | 2362 } |
2363 | 2363 |
2364 ComplexMatrix& | 2364 ComplexMatrix& |
2365 ComplexMatrix::operator -= (const ComplexDiagMatrix& a) | 2365 ComplexMatrix::operator -= (const ComplexDiagMatrix& a) |
2366 { | 2366 { |
2367 int nr = rows (); | 2367 octave_idx_type nr = rows (); |
2368 int nc = cols (); | 2368 octave_idx_type nc = cols (); |
2369 | 2369 |
2370 int a_nr = rows (); | 2370 octave_idx_type a_nr = rows (); |
2371 int a_nc = cols (); | 2371 octave_idx_type a_nc = cols (); |
2372 | 2372 |
2373 if (nr != a_nr || nc != a_nc) | 2373 if (nr != a_nr || nc != a_nc) |
2374 { | 2374 { |
2375 gripe_nonconformant ("operator -=", nr, nc, a_nr, a_nc); | 2375 gripe_nonconformant ("operator -=", nr, nc, a_nr, a_nc); |
2376 return *this; | 2376 return *this; |
2377 } | 2377 } |
2378 | 2378 |
2379 for (int i = 0; i < a.length (); i++) | 2379 for (octave_idx_type i = 0; i < a.length (); i++) |
2380 elem (i, i) -= a.elem (i, i); | 2380 elem (i, i) -= a.elem (i, i); |
2381 | 2381 |
2382 return *this; | 2382 return *this; |
2383 } | 2383 } |
2384 | 2384 |
2385 // matrix by matrix -> matrix operations | 2385 // matrix by matrix -> matrix operations |
2386 | 2386 |
2387 ComplexMatrix& | 2387 ComplexMatrix& |
2388 ComplexMatrix::operator += (const Matrix& a) | 2388 ComplexMatrix::operator += (const Matrix& a) |
2389 { | 2389 { |
2390 int nr = rows (); | 2390 octave_idx_type nr = rows (); |
2391 int nc = cols (); | 2391 octave_idx_type nc = cols (); |
2392 | 2392 |
2393 int a_nr = a.rows (); | 2393 octave_idx_type a_nr = a.rows (); |
2394 int a_nc = a.cols (); | 2394 octave_idx_type a_nc = a.cols (); |
2395 | 2395 |
2396 if (nr != a_nr || nc != a_nc) | 2396 if (nr != a_nr || nc != a_nc) |
2397 { | 2397 { |
2398 gripe_nonconformant ("operator +=", nr, nc, a_nr, a_nc); | 2398 gripe_nonconformant ("operator +=", nr, nc, a_nr, a_nc); |
2399 return *this; | 2399 return *this; |
2409 } | 2409 } |
2410 | 2410 |
2411 ComplexMatrix& | 2411 ComplexMatrix& |
2412 ComplexMatrix::operator -= (const Matrix& a) | 2412 ComplexMatrix::operator -= (const Matrix& a) |
2413 { | 2413 { |
2414 int nr = rows (); | 2414 octave_idx_type nr = rows (); |
2415 int nc = cols (); | 2415 octave_idx_type nc = cols (); |
2416 | 2416 |
2417 int a_nr = a.rows (); | 2417 octave_idx_type a_nr = a.rows (); |
2418 int a_nc = a.cols (); | 2418 octave_idx_type a_nc = a.cols (); |
2419 | 2419 |
2420 if (nr != a_nr || nc != a_nc) | 2420 if (nr != a_nr || nc != a_nc) |
2421 { | 2421 { |
2422 gripe_nonconformant ("operator -=", nr, nc, a_nr, a_nc); | 2422 gripe_nonconformant ("operator -=", nr, nc, a_nr, a_nc); |
2423 return *this; | 2423 return *this; |
2435 // unary operations | 2435 // unary operations |
2436 | 2436 |
2437 boolMatrix | 2437 boolMatrix |
2438 ComplexMatrix::operator ! (void) const | 2438 ComplexMatrix::operator ! (void) const |
2439 { | 2439 { |
2440 int nr = rows (); | 2440 octave_idx_type nr = rows (); |
2441 int nc = cols (); | 2441 octave_idx_type nc = cols (); |
2442 | 2442 |
2443 boolMatrix b (nr, nc); | 2443 boolMatrix b (nr, nc); |
2444 | 2444 |
2445 for (int j = 0; j < nc; j++) | 2445 for (octave_idx_type j = 0; j < nc; j++) |
2446 for (int i = 0; i < nr; i++) | 2446 for (octave_idx_type i = 0; i < nr; i++) |
2447 b.elem (i, j) = elem (i, j) == 0.0; | 2447 b.elem (i, j) = elem (i, j) == 0.0; |
2448 | 2448 |
2449 return b; | 2449 return b; |
2450 } | 2450 } |
2451 | 2451 |
2459 } | 2459 } |
2460 | 2460 |
2461 Matrix | 2461 Matrix |
2462 ComplexMatrix::map (d_c_Mapper f) const | 2462 ComplexMatrix::map (d_c_Mapper f) const |
2463 { | 2463 { |
2464 int nr = rows (); | 2464 octave_idx_type nr = rows (); |
2465 int nc = cols (); | 2465 octave_idx_type nc = cols (); |
2466 | 2466 |
2467 Matrix retval (nr, nc); | 2467 Matrix retval (nr, nc); |
2468 | 2468 |
2469 for (int j = 0; j < nc; j++) | 2469 for (octave_idx_type j = 0; j < nc; j++) |
2470 for (int i = 0; i < nr; i++) | 2470 for (octave_idx_type i = 0; i < nr; i++) |
2471 retval(i,j) = f (elem(i,j)); | 2471 retval(i,j) = f (elem(i,j)); |
2472 | 2472 |
2473 return retval; | 2473 return retval; |
2474 } | 2474 } |
2475 | 2475 |
2476 boolMatrix | 2476 boolMatrix |
2477 ComplexMatrix::map (b_c_Mapper f) const | 2477 ComplexMatrix::map (b_c_Mapper f) const |
2478 { | 2478 { |
2479 int nr = rows (); | 2479 octave_idx_type nr = rows (); |
2480 int nc = cols (); | 2480 octave_idx_type nc = cols (); |
2481 | 2481 |
2482 boolMatrix retval (nr, nc); | 2482 boolMatrix retval (nr, nc); |
2483 | 2483 |
2484 for (int j = 0; j < nc; j++) | 2484 for (octave_idx_type j = 0; j < nc; j++) |
2485 for (int i = 0; i < nr; i++) | 2485 for (octave_idx_type i = 0; i < nr; i++) |
2486 retval(i,j) = f (elem(i,j)); | 2486 retval(i,j) = f (elem(i,j)); |
2487 | 2487 |
2488 return retval; | 2488 return retval; |
2489 } | 2489 } |
2490 | 2490 |
2491 ComplexMatrix& | 2491 ComplexMatrix& |
2492 ComplexMatrix::apply (c_c_Mapper f) | 2492 ComplexMatrix::apply (c_c_Mapper f) |
2493 { | 2493 { |
2494 Complex *d = fortran_vec (); // Ensures only one reference to my privates! | 2494 Complex *d = fortran_vec (); // Ensures only one reference to my privates! |
2495 | 2495 |
2496 for (int i = 0; i < length (); i++) | 2496 for (octave_idx_type i = 0; i < length (); i++) |
2497 d[i] = f (d[i]); | 2497 d[i] = f (d[i]); |
2498 | 2498 |
2499 return *this; | 2499 return *this; |
2500 } | 2500 } |
2501 | 2501 |
2502 bool | 2502 bool |
2503 ComplexMatrix::any_element_is_inf_or_nan (void) const | 2503 ComplexMatrix::any_element_is_inf_or_nan (void) const |
2504 { | 2504 { |
2505 int nr = rows (); | 2505 octave_idx_type nr = rows (); |
2506 int nc = cols (); | 2506 octave_idx_type nc = cols (); |
2507 | 2507 |
2508 for (int j = 0; j < nc; j++) | 2508 for (octave_idx_type j = 0; j < nc; j++) |
2509 for (int i = 0; i < nr; i++) | 2509 for (octave_idx_type i = 0; i < nr; i++) |
2510 { | 2510 { |
2511 Complex val = elem (i, j); | 2511 Complex val = elem (i, j); |
2512 if (xisinf (val) || xisnan (val)) | 2512 if (xisinf (val) || xisnan (val)) |
2513 return true; | 2513 return true; |
2514 } | 2514 } |
2519 // Return true if no elements have imaginary components. | 2519 // Return true if no elements have imaginary components. |
2520 | 2520 |
2521 bool | 2521 bool |
2522 ComplexMatrix::all_elements_are_real (void) const | 2522 ComplexMatrix::all_elements_are_real (void) const |
2523 { | 2523 { |
2524 int nr = rows (); | 2524 octave_idx_type nr = rows (); |
2525 int nc = cols (); | 2525 octave_idx_type nc = cols (); |
2526 | 2526 |
2527 for (int j = 0; j < nc; j++) | 2527 for (octave_idx_type j = 0; j < nc; j++) |
2528 { | 2528 { |
2529 for (int i = 0; i < nr; i++) | 2529 for (octave_idx_type i = 0; i < nr; i++) |
2530 { | 2530 { |
2531 double ip = STD_OCTAVE::imag (elem (i, j)); | 2531 double ip = STD_OCTAVE::imag (elem (i, j)); |
2532 | 2532 |
2533 if (ip != 0.0 || lo_ieee_signbit (ip)) | 2533 if (ip != 0.0 || lo_ieee_signbit (ip)) |
2534 return false; | 2534 return false; |
2543 // imaginary) values and return them in MAX_VAL and MIN_VAL. | 2543 // imaginary) values and return them in MAX_VAL and MIN_VAL. |
2544 | 2544 |
2545 bool | 2545 bool |
2546 ComplexMatrix::all_integers (double& max_val, double& min_val) const | 2546 ComplexMatrix::all_integers (double& max_val, double& min_val) const |
2547 { | 2547 { |
2548 int nr = rows (); | 2548 octave_idx_type nr = rows (); |
2549 int nc = cols (); | 2549 octave_idx_type nc = cols (); |
2550 | 2550 |
2551 if (nr > 0 && nc > 0) | 2551 if (nr > 0 && nc > 0) |
2552 { | 2552 { |
2553 Complex val = elem (0, 0); | 2553 Complex val = elem (0, 0); |
2554 | 2554 |
2565 min_val = i_val; | 2565 min_val = i_val; |
2566 } | 2566 } |
2567 else | 2567 else |
2568 return false; | 2568 return false; |
2569 | 2569 |
2570 for (int j = 0; j < nc; j++) | 2570 for (octave_idx_type j = 0; j < nc; j++) |
2571 for (int i = 0; i < nr; i++) | 2571 for (octave_idx_type i = 0; i < nr; i++) |
2572 { | 2572 { |
2573 Complex val = elem (i, j); | 2573 Complex val = elem (i, j); |
2574 | 2574 |
2575 double r_val = STD_OCTAVE::real (val); | 2575 double r_val = STD_OCTAVE::real (val); |
2576 double i_val = STD_OCTAVE::imag (val); | 2576 double i_val = STD_OCTAVE::imag (val); |
2595 } | 2595 } |
2596 | 2596 |
2597 bool | 2597 bool |
2598 ComplexMatrix::too_large_for_float (void) const | 2598 ComplexMatrix::too_large_for_float (void) const |
2599 { | 2599 { |
2600 int nr = rows (); | 2600 octave_idx_type nr = rows (); |
2601 int nc = cols (); | 2601 octave_idx_type nc = cols (); |
2602 | 2602 |
2603 for (int j = 0; j < nc; j++) | 2603 for (octave_idx_type j = 0; j < nc; j++) |
2604 for (int i = 0; i < nr; i++) | 2604 for (octave_idx_type i = 0; i < nr; i++) |
2605 { | 2605 { |
2606 Complex val = elem (i, j); | 2606 Complex val = elem (i, j); |
2607 | 2607 |
2608 double r_val = STD_OCTAVE::real (val); | 2608 double r_val = STD_OCTAVE::real (val); |
2609 double i_val = STD_OCTAVE::imag (val); | 2609 double i_val = STD_OCTAVE::imag (val); |
2674 #undef COL_EXPR | 2674 #undef COL_EXPR |
2675 } | 2675 } |
2676 | 2676 |
2677 Matrix ComplexMatrix::abs (void) const | 2677 Matrix ComplexMatrix::abs (void) const |
2678 { | 2678 { |
2679 int nr = rows (); | 2679 octave_idx_type nr = rows (); |
2680 int nc = cols (); | 2680 octave_idx_type nc = cols (); |
2681 | 2681 |
2682 Matrix retval (nr, nc); | 2682 Matrix retval (nr, nc); |
2683 | 2683 |
2684 for (int j = 0; j < nc; j++) | 2684 for (octave_idx_type j = 0; j < nc; j++) |
2685 for (int i = 0; i < nr; i++) | 2685 for (octave_idx_type i = 0; i < nr; i++) |
2686 retval (i, j) = STD_OCTAVE::abs (elem (i, j)); | 2686 retval (i, j) = STD_OCTAVE::abs (elem (i, j)); |
2687 | 2687 |
2688 return retval; | 2688 return retval; |
2689 } | 2689 } |
2690 | 2690 |
2693 { | 2693 { |
2694 return diag (0); | 2694 return diag (0); |
2695 } | 2695 } |
2696 | 2696 |
2697 ComplexColumnVector | 2697 ComplexColumnVector |
2698 ComplexMatrix::diag (int k) const | 2698 ComplexMatrix::diag (octave_idx_type k) const |
2699 { | 2699 { |
2700 int nnr = rows (); | 2700 octave_idx_type nnr = rows (); |
2701 int nnc = cols (); | 2701 octave_idx_type nnc = cols (); |
2702 if (k > 0) | 2702 if (k > 0) |
2703 nnc -= k; | 2703 nnc -= k; |
2704 else if (k < 0) | 2704 else if (k < 0) |
2705 nnr += k; | 2705 nnr += k; |
2706 | 2706 |
2707 ComplexColumnVector d; | 2707 ComplexColumnVector d; |
2708 | 2708 |
2709 if (nnr > 0 && nnc > 0) | 2709 if (nnr > 0 && nnc > 0) |
2710 { | 2710 { |
2711 int ndiag = (nnr < nnc) ? nnr : nnc; | 2711 octave_idx_type ndiag = (nnr < nnc) ? nnr : nnc; |
2712 | 2712 |
2713 d.resize (ndiag); | 2713 d.resize (ndiag); |
2714 | 2714 |
2715 if (k > 0) | 2715 if (k > 0) |
2716 { | 2716 { |
2717 for (int i = 0; i < ndiag; i++) | 2717 for (octave_idx_type i = 0; i < ndiag; i++) |
2718 d.elem (i) = elem (i, i+k); | 2718 d.elem (i) = elem (i, i+k); |
2719 } | 2719 } |
2720 else if (k < 0) | 2720 else if (k < 0) |
2721 { | 2721 { |
2722 for (int i = 0; i < ndiag; i++) | 2722 for (octave_idx_type i = 0; i < ndiag; i++) |
2723 d.elem (i) = elem (i-k, i); | 2723 d.elem (i) = elem (i-k, i); |
2724 } | 2724 } |
2725 else | 2725 else |
2726 { | 2726 { |
2727 for (int i = 0; i < ndiag; i++) | 2727 for (octave_idx_type i = 0; i < ndiag; i++) |
2728 d.elem (i) = elem (i, i); | 2728 d.elem (i) = elem (i, i); |
2729 } | 2729 } |
2730 } | 2730 } |
2731 else | 2731 else |
2732 (*current_liboctave_error_handler) | 2732 (*current_liboctave_error_handler) |
2734 | 2734 |
2735 return d; | 2735 return d; |
2736 } | 2736 } |
2737 | 2737 |
2738 bool | 2738 bool |
2739 ComplexMatrix::row_is_real_only (int i) const | 2739 ComplexMatrix::row_is_real_only (octave_idx_type i) const |
2740 { | 2740 { |
2741 bool retval = true; | 2741 bool retval = true; |
2742 | 2742 |
2743 int nc = columns (); | 2743 octave_idx_type nc = columns (); |
2744 | 2744 |
2745 for (int j = 0; j < nc; j++) | 2745 for (octave_idx_type j = 0; j < nc; j++) |
2746 { | 2746 { |
2747 if (STD_OCTAVE::imag (elem (i, j)) != 0.0) | 2747 if (STD_OCTAVE::imag (elem (i, j)) != 0.0) |
2748 { | 2748 { |
2749 retval = false; | 2749 retval = false; |
2750 break; | 2750 break; |
2753 | 2753 |
2754 return retval; | 2754 return retval; |
2755 } | 2755 } |
2756 | 2756 |
2757 bool | 2757 bool |
2758 ComplexMatrix::column_is_real_only (int j) const | 2758 ComplexMatrix::column_is_real_only (octave_idx_type j) const |
2759 { | 2759 { |
2760 bool retval = true; | 2760 bool retval = true; |
2761 | 2761 |
2762 int nr = rows (); | 2762 octave_idx_type nr = rows (); |
2763 | 2763 |
2764 for (int i = 0; i < nr; i++) | 2764 for (octave_idx_type i = 0; i < nr; i++) |
2765 { | 2765 { |
2766 if (STD_OCTAVE::imag (elem (i, j)) != 0.0) | 2766 if (STD_OCTAVE::imag (elem (i, j)) != 0.0) |
2767 { | 2767 { |
2768 retval = false; | 2768 retval = false; |
2769 break; | 2769 break; |
2774 } | 2774 } |
2775 | 2775 |
2776 ComplexColumnVector | 2776 ComplexColumnVector |
2777 ComplexMatrix::row_min (void) const | 2777 ComplexMatrix::row_min (void) const |
2778 { | 2778 { |
2779 Array<int> dummy_idx; | 2779 Array<octave_idx_type> dummy_idx; |
2780 return row_min (dummy_idx); | 2780 return row_min (dummy_idx); |
2781 } | 2781 } |
2782 | 2782 |
2783 ComplexColumnVector | 2783 ComplexColumnVector |
2784 ComplexMatrix::row_min (Array<int>& idx_arg) const | 2784 ComplexMatrix::row_min (Array<octave_idx_type>& idx_arg) const |
2785 { | 2785 { |
2786 ComplexColumnVector result; | 2786 ComplexColumnVector result; |
2787 | 2787 |
2788 int nr = rows (); | 2788 octave_idx_type nr = rows (); |
2789 int nc = cols (); | 2789 octave_idx_type nc = cols (); |
2790 | 2790 |
2791 if (nr > 0 && nc > 0) | 2791 if (nr > 0 && nc > 0) |
2792 { | 2792 { |
2793 result.resize (nr); | 2793 result.resize (nr); |
2794 idx_arg.resize (nr); | 2794 idx_arg.resize (nr); |
2795 | 2795 |
2796 for (int i = 0; i < nr; i++) | 2796 for (octave_idx_type i = 0; i < nr; i++) |
2797 { | 2797 { |
2798 bool real_only = row_is_real_only (i); | 2798 bool real_only = row_is_real_only (i); |
2799 | 2799 |
2800 int idx_j; | 2800 octave_idx_type idx_j; |
2801 | 2801 |
2802 Complex tmp_min; | 2802 Complex tmp_min; |
2803 | 2803 |
2804 double abs_min = octave_NaN; | 2804 double abs_min = octave_NaN; |
2805 | 2805 |
2812 abs_min = real_only ? STD_OCTAVE::real (tmp_min) : STD_OCTAVE::abs (tmp_min); | 2812 abs_min = real_only ? STD_OCTAVE::real (tmp_min) : STD_OCTAVE::abs (tmp_min); |
2813 break; | 2813 break; |
2814 } | 2814 } |
2815 } | 2815 } |
2816 | 2816 |
2817 for (int j = idx_j+1; j < nc; j++) | 2817 for (octave_idx_type j = idx_j+1; j < nc; j++) |
2818 { | 2818 { |
2819 Complex tmp = elem (i, j); | 2819 Complex tmp = elem (i, j); |
2820 | 2820 |
2821 if (octave_is_NaN_or_NA (tmp)) | 2821 if (octave_is_NaN_or_NA (tmp)) |
2822 continue; | 2822 continue; |
2848 } | 2848 } |
2849 | 2849 |
2850 ComplexColumnVector | 2850 ComplexColumnVector |
2851 ComplexMatrix::row_max (void) const | 2851 ComplexMatrix::row_max (void) const |
2852 { | 2852 { |
2853 Array<int> dummy_idx; | 2853 Array<octave_idx_type> dummy_idx; |
2854 return row_max (dummy_idx); | 2854 return row_max (dummy_idx); |
2855 } | 2855 } |
2856 | 2856 |
2857 ComplexColumnVector | 2857 ComplexColumnVector |
2858 ComplexMatrix::row_max (Array<int>& idx_arg) const | 2858 ComplexMatrix::row_max (Array<octave_idx_type>& idx_arg) const |
2859 { | 2859 { |
2860 ComplexColumnVector result; | 2860 ComplexColumnVector result; |
2861 | 2861 |
2862 int nr = rows (); | 2862 octave_idx_type nr = rows (); |
2863 int nc = cols (); | 2863 octave_idx_type nc = cols (); |
2864 | 2864 |
2865 if (nr > 0 && nc > 0) | 2865 if (nr > 0 && nc > 0) |
2866 { | 2866 { |
2867 result.resize (nr); | 2867 result.resize (nr); |
2868 idx_arg.resize (nr); | 2868 idx_arg.resize (nr); |
2869 | 2869 |
2870 for (int i = 0; i < nr; i++) | 2870 for (octave_idx_type i = 0; i < nr; i++) |
2871 { | 2871 { |
2872 bool real_only = row_is_real_only (i); | 2872 bool real_only = row_is_real_only (i); |
2873 | 2873 |
2874 int idx_j; | 2874 octave_idx_type idx_j; |
2875 | 2875 |
2876 Complex tmp_max; | 2876 Complex tmp_max; |
2877 | 2877 |
2878 double abs_max = octave_NaN; | 2878 double abs_max = octave_NaN; |
2879 | 2879 |
2886 abs_max = real_only ? STD_OCTAVE::real (tmp_max) : STD_OCTAVE::abs (tmp_max); | 2886 abs_max = real_only ? STD_OCTAVE::real (tmp_max) : STD_OCTAVE::abs (tmp_max); |
2887 break; | 2887 break; |
2888 } | 2888 } |
2889 } | 2889 } |
2890 | 2890 |
2891 for (int j = idx_j+1; j < nc; j++) | 2891 for (octave_idx_type j = idx_j+1; j < nc; j++) |
2892 { | 2892 { |
2893 Complex tmp = elem (i, j); | 2893 Complex tmp = elem (i, j); |
2894 | 2894 |
2895 if (octave_is_NaN_or_NA (tmp)) | 2895 if (octave_is_NaN_or_NA (tmp)) |
2896 continue; | 2896 continue; |
2922 } | 2922 } |
2923 | 2923 |
2924 ComplexRowVector | 2924 ComplexRowVector |
2925 ComplexMatrix::column_min (void) const | 2925 ComplexMatrix::column_min (void) const |
2926 { | 2926 { |
2927 Array<int> dummy_idx; | 2927 Array<octave_idx_type> dummy_idx; |
2928 return column_min (dummy_idx); | 2928 return column_min (dummy_idx); |
2929 } | 2929 } |
2930 | 2930 |
2931 ComplexRowVector | 2931 ComplexRowVector |
2932 ComplexMatrix::column_min (Array<int>& idx_arg) const | 2932 ComplexMatrix::column_min (Array<octave_idx_type>& idx_arg) const |
2933 { | 2933 { |
2934 ComplexRowVector result; | 2934 ComplexRowVector result; |
2935 | 2935 |
2936 int nr = rows (); | 2936 octave_idx_type nr = rows (); |
2937 int nc = cols (); | 2937 octave_idx_type nc = cols (); |
2938 | 2938 |
2939 if (nr > 0 && nc > 0) | 2939 if (nr > 0 && nc > 0) |
2940 { | 2940 { |
2941 result.resize (nc); | 2941 result.resize (nc); |
2942 idx_arg.resize (nc); | 2942 idx_arg.resize (nc); |
2943 | 2943 |
2944 for (int j = 0; j < nc; j++) | 2944 for (octave_idx_type j = 0; j < nc; j++) |
2945 { | 2945 { |
2946 bool real_only = column_is_real_only (j); | 2946 bool real_only = column_is_real_only (j); |
2947 | 2947 |
2948 int idx_i; | 2948 octave_idx_type idx_i; |
2949 | 2949 |
2950 Complex tmp_min; | 2950 Complex tmp_min; |
2951 | 2951 |
2952 double abs_min = octave_NaN; | 2952 double abs_min = octave_NaN; |
2953 | 2953 |
2960 abs_min = real_only ? STD_OCTAVE::real (tmp_min) : STD_OCTAVE::abs (tmp_min); | 2960 abs_min = real_only ? STD_OCTAVE::real (tmp_min) : STD_OCTAVE::abs (tmp_min); |
2961 break; | 2961 break; |
2962 } | 2962 } |
2963 } | 2963 } |
2964 | 2964 |
2965 for (int i = idx_i+1; i < nr; i++) | 2965 for (octave_idx_type i = idx_i+1; i < nr; i++) |
2966 { | 2966 { |
2967 Complex tmp = elem (i, j); | 2967 Complex tmp = elem (i, j); |
2968 | 2968 |
2969 if (octave_is_NaN_or_NA (tmp)) | 2969 if (octave_is_NaN_or_NA (tmp)) |
2970 continue; | 2970 continue; |
2996 } | 2996 } |
2997 | 2997 |
2998 ComplexRowVector | 2998 ComplexRowVector |
2999 ComplexMatrix::column_max (void) const | 2999 ComplexMatrix::column_max (void) const |
3000 { | 3000 { |
3001 Array<int> dummy_idx; | 3001 Array<octave_idx_type> dummy_idx; |
3002 return column_max (dummy_idx); | 3002 return column_max (dummy_idx); |
3003 } | 3003 } |
3004 | 3004 |
3005 ComplexRowVector | 3005 ComplexRowVector |
3006 ComplexMatrix::column_max (Array<int>& idx_arg) const | 3006 ComplexMatrix::column_max (Array<octave_idx_type>& idx_arg) const |
3007 { | 3007 { |
3008 ComplexRowVector result; | 3008 ComplexRowVector result; |
3009 | 3009 |
3010 int nr = rows (); | 3010 octave_idx_type nr = rows (); |
3011 int nc = cols (); | 3011 octave_idx_type nc = cols (); |
3012 | 3012 |
3013 if (nr > 0 && nc > 0) | 3013 if (nr > 0 && nc > 0) |
3014 { | 3014 { |
3015 result.resize (nc); | 3015 result.resize (nc); |
3016 idx_arg.resize (nc); | 3016 idx_arg.resize (nc); |
3017 | 3017 |
3018 for (int j = 0; j < nc; j++) | 3018 for (octave_idx_type j = 0; j < nc; j++) |
3019 { | 3019 { |
3020 bool real_only = column_is_real_only (j); | 3020 bool real_only = column_is_real_only (j); |
3021 | 3021 |
3022 int idx_i; | 3022 octave_idx_type idx_i; |
3023 | 3023 |
3024 Complex tmp_max; | 3024 Complex tmp_max; |
3025 | 3025 |
3026 double abs_max = octave_NaN; | 3026 double abs_max = octave_NaN; |
3027 | 3027 |
3034 abs_max = real_only ? STD_OCTAVE::real (tmp_max) : STD_OCTAVE::abs (tmp_max); | 3034 abs_max = real_only ? STD_OCTAVE::real (tmp_max) : STD_OCTAVE::abs (tmp_max); |
3035 break; | 3035 break; |
3036 } | 3036 } |
3037 } | 3037 } |
3038 | 3038 |
3039 for (int i = idx_i+1; i < nr; i++) | 3039 for (octave_idx_type i = idx_i+1; i < nr; i++) |
3040 { | 3040 { |
3041 Complex tmp = elem (i, j); | 3041 Complex tmp = elem (i, j); |
3042 | 3042 |
3043 if (octave_is_NaN_or_NA (tmp)) | 3043 if (octave_is_NaN_or_NA (tmp)) |
3044 continue; | 3044 continue; |
3072 // i/o | 3072 // i/o |
3073 | 3073 |
3074 std::ostream& | 3074 std::ostream& |
3075 operator << (std::ostream& os, const ComplexMatrix& a) | 3075 operator << (std::ostream& os, const ComplexMatrix& a) |
3076 { | 3076 { |
3077 for (int i = 0; i < a.rows (); i++) | 3077 for (octave_idx_type i = 0; i < a.rows (); i++) |
3078 { | 3078 { |
3079 for (int j = 0; j < a.cols (); j++) | 3079 for (octave_idx_type j = 0; j < a.cols (); j++) |
3080 { | 3080 { |
3081 os << " "; | 3081 os << " "; |
3082 octave_write_complex (os, a.elem (i, j)); | 3082 octave_write_complex (os, a.elem (i, j)); |
3083 } | 3083 } |
3084 os << "\n"; | 3084 os << "\n"; |
3087 } | 3087 } |
3088 | 3088 |
3089 std::istream& | 3089 std::istream& |
3090 operator >> (std::istream& is, ComplexMatrix& a) | 3090 operator >> (std::istream& is, ComplexMatrix& a) |
3091 { | 3091 { |
3092 int nr = a.rows (); | 3092 octave_idx_type nr = a.rows (); |
3093 int nc = a.cols (); | 3093 octave_idx_type nc = a.cols (); |
3094 | 3094 |
3095 if (nr < 1 || nc < 1) | 3095 if (nr < 1 || nc < 1) |
3096 is.clear (std::ios::badbit); | 3096 is.clear (std::ios::badbit); |
3097 else | 3097 else |
3098 { | 3098 { |
3099 Complex tmp; | 3099 Complex tmp; |
3100 for (int i = 0; i < nr; i++) | 3100 for (octave_idx_type i = 0; i < nr; i++) |
3101 for (int j = 0; j < nc; j++) | 3101 for (octave_idx_type j = 0; j < nc; j++) |
3102 { | 3102 { |
3103 tmp = octave_read_complex (is); | 3103 tmp = octave_read_complex (is); |
3104 if (is) | 3104 if (is) |
3105 a.elem (i, j) = tmp; | 3105 a.elem (i, j) = tmp; |
3106 else | 3106 else |
3156 ComplexMatrix cx = ua.hermitian () * c * ub; | 3156 ComplexMatrix cx = ua.hermitian () * c * ub; |
3157 | 3157 |
3158 // Solve the sylvester equation, back-transform, and return the | 3158 // Solve the sylvester equation, back-transform, and return the |
3159 // solution. | 3159 // solution. |
3160 | 3160 |
3161 int a_nr = a.rows (); | 3161 octave_idx_type a_nr = a.rows (); |
3162 int b_nr = b.rows (); | 3162 octave_idx_type b_nr = b.rows (); |
3163 | 3163 |
3164 double scale; | 3164 double scale; |
3165 int info; | 3165 octave_idx_type info; |
3166 | 3166 |
3167 Complex *pa = sch_a.fortran_vec (); | 3167 Complex *pa = sch_a.fortran_vec (); |
3168 Complex *pb = sch_b.fortran_vec (); | 3168 Complex *pb = sch_b.fortran_vec (); |
3169 Complex *px = cx.fortran_vec (); | 3169 Complex *px = cx.fortran_vec (); |
3170 | 3170 |
3204 ComplexMatrix | 3204 ComplexMatrix |
3205 operator * (const ComplexMatrix& m, const ComplexMatrix& a) | 3205 operator * (const ComplexMatrix& m, const ComplexMatrix& a) |
3206 { | 3206 { |
3207 ComplexMatrix retval; | 3207 ComplexMatrix retval; |
3208 | 3208 |
3209 int nr = m.rows (); | 3209 octave_idx_type nr = m.rows (); |
3210 int nc = m.cols (); | 3210 octave_idx_type nc = m.cols (); |
3211 | 3211 |
3212 int a_nr = a.rows (); | 3212 octave_idx_type a_nr = a.rows (); |
3213 int a_nc = a.cols (); | 3213 octave_idx_type a_nc = a.cols (); |
3214 | 3214 |
3215 if (nc != a_nr) | 3215 if (nc != a_nr) |
3216 gripe_nonconformant ("operator *", nr, nc, a_nr, a_nc); | 3216 gripe_nonconformant ("operator *", nr, nc, a_nr, a_nc); |
3217 else | 3217 else |
3218 { | 3218 { |
3219 if (nr == 0 || nc == 0 || a_nc == 0) | 3219 if (nr == 0 || nc == 0 || a_nc == 0) |
3220 retval.resize (nr, a_nc, 0.0); | 3220 retval.resize (nr, a_nc, 0.0); |
3221 else | 3221 else |
3222 { | 3222 { |
3223 int ld = nr; | 3223 octave_idx_type ld = nr; |
3224 int lda = a.rows (); | 3224 octave_idx_type lda = a.rows (); |
3225 | 3225 |
3226 retval.resize (nr, a_nc); | 3226 retval.resize (nr, a_nc); |
3227 Complex *c = retval.fortran_vec (); | 3227 Complex *c = retval.fortran_vec (); |
3228 | 3228 |
3229 F77_XFCN (zgemm, ZGEMM, (F77_CONST_CHAR_ARG2 ("N", 1), | 3229 F77_XFCN (zgemm, ZGEMM, (F77_CONST_CHAR_ARG2 ("N", 1), |
3250 return T (nr, nc); | 3250 return T (nr, nc); |
3251 | 3251 |
3252 ComplexMatrix | 3252 ComplexMatrix |
3253 min (const Complex& c, const ComplexMatrix& m) | 3253 min (const Complex& c, const ComplexMatrix& m) |
3254 { | 3254 { |
3255 int nr = m.rows (); | 3255 octave_idx_type nr = m.rows (); |
3256 int nc = m.columns (); | 3256 octave_idx_type nc = m.columns (); |
3257 | 3257 |
3258 EMPTY_RETURN_CHECK (ComplexMatrix); | 3258 EMPTY_RETURN_CHECK (ComplexMatrix); |
3259 | 3259 |
3260 ComplexMatrix result (nr, nc); | 3260 ComplexMatrix result (nr, nc); |
3261 | 3261 |
3262 for (int j = 0; j < nc; j++) | 3262 for (octave_idx_type j = 0; j < nc; j++) |
3263 for (int i = 0; i < nr; i++) | 3263 for (octave_idx_type i = 0; i < nr; i++) |
3264 { | 3264 { |
3265 OCTAVE_QUIT; | 3265 OCTAVE_QUIT; |
3266 result (i, j) = xmin (c, m (i, j)); | 3266 result (i, j) = xmin (c, m (i, j)); |
3267 } | 3267 } |
3268 | 3268 |
3270 } | 3270 } |
3271 | 3271 |
3272 ComplexMatrix | 3272 ComplexMatrix |
3273 min (const ComplexMatrix& m, const Complex& c) | 3273 min (const ComplexMatrix& m, const Complex& c) |
3274 { | 3274 { |
3275 int nr = m.rows (); | 3275 octave_idx_type nr = m.rows (); |
3276 int nc = m.columns (); | 3276 octave_idx_type nc = m.columns (); |
3277 | 3277 |
3278 EMPTY_RETURN_CHECK (ComplexMatrix); | 3278 EMPTY_RETURN_CHECK (ComplexMatrix); |
3279 | 3279 |
3280 ComplexMatrix result (nr, nc); | 3280 ComplexMatrix result (nr, nc); |
3281 | 3281 |
3282 for (int j = 0; j < nc; j++) | 3282 for (octave_idx_type j = 0; j < nc; j++) |
3283 for (int i = 0; i < nr; i++) | 3283 for (octave_idx_type i = 0; i < nr; i++) |
3284 { | 3284 { |
3285 OCTAVE_QUIT; | 3285 OCTAVE_QUIT; |
3286 result (i, j) = xmin (m (i, j), c); | 3286 result (i, j) = xmin (m (i, j), c); |
3287 } | 3287 } |
3288 | 3288 |
3290 } | 3290 } |
3291 | 3291 |
3292 ComplexMatrix | 3292 ComplexMatrix |
3293 min (const ComplexMatrix& a, const ComplexMatrix& b) | 3293 min (const ComplexMatrix& a, const ComplexMatrix& b) |
3294 { | 3294 { |
3295 int nr = a.rows (); | 3295 octave_idx_type nr = a.rows (); |
3296 int nc = a.columns (); | 3296 octave_idx_type nc = a.columns (); |
3297 | 3297 |
3298 if (nr != b.rows () || nc != b.columns ()) | 3298 if (nr != b.rows () || nc != b.columns ()) |
3299 { | 3299 { |
3300 (*current_liboctave_error_handler) | 3300 (*current_liboctave_error_handler) |
3301 ("two-arg min expecting args of same size"); | 3301 ("two-arg min expecting args of same size"); |
3304 | 3304 |
3305 EMPTY_RETURN_CHECK (ComplexMatrix); | 3305 EMPTY_RETURN_CHECK (ComplexMatrix); |
3306 | 3306 |
3307 ComplexMatrix result (nr, nc); | 3307 ComplexMatrix result (nr, nc); |
3308 | 3308 |
3309 for (int j = 0; j < nc; j++) | 3309 for (octave_idx_type j = 0; j < nc; j++) |
3310 { | 3310 { |
3311 int columns_are_real_only = 1; | 3311 int columns_are_real_only = 1; |
3312 for (int i = 0; i < nr; i++) | 3312 for (octave_idx_type i = 0; i < nr; i++) |
3313 { | 3313 { |
3314 OCTAVE_QUIT; | 3314 OCTAVE_QUIT; |
3315 if (STD_OCTAVE::imag (a (i, j)) != 0.0 || STD_OCTAVE::imag (b (i, j)) != 0.0) | 3315 if (STD_OCTAVE::imag (a (i, j)) != 0.0 || STD_OCTAVE::imag (b (i, j)) != 0.0) |
3316 { | 3316 { |
3317 columns_are_real_only = 0; | 3317 columns_are_real_only = 0; |
3319 } | 3319 } |
3320 } | 3320 } |
3321 | 3321 |
3322 if (columns_are_real_only) | 3322 if (columns_are_real_only) |
3323 { | 3323 { |
3324 for (int i = 0; i < nr; i++) | 3324 for (octave_idx_type i = 0; i < nr; i++) |
3325 result (i, j) = xmin (STD_OCTAVE::real (a (i, j)), STD_OCTAVE::real (b (i, j))); | 3325 result (i, j) = xmin (STD_OCTAVE::real (a (i, j)), STD_OCTAVE::real (b (i, j))); |
3326 } | 3326 } |
3327 else | 3327 else |
3328 { | 3328 { |
3329 for (int i = 0; i < nr; i++) | 3329 for (octave_idx_type i = 0; i < nr; i++) |
3330 { | 3330 { |
3331 OCTAVE_QUIT; | 3331 OCTAVE_QUIT; |
3332 result (i, j) = xmin (a (i, j), b (i, j)); | 3332 result (i, j) = xmin (a (i, j), b (i, j)); |
3333 } | 3333 } |
3334 } | 3334 } |
3338 } | 3338 } |
3339 | 3339 |
3340 ComplexMatrix | 3340 ComplexMatrix |
3341 max (const Complex& c, const ComplexMatrix& m) | 3341 max (const Complex& c, const ComplexMatrix& m) |
3342 { | 3342 { |
3343 int nr = m.rows (); | 3343 octave_idx_type nr = m.rows (); |
3344 int nc = m.columns (); | 3344 octave_idx_type nc = m.columns (); |
3345 | 3345 |
3346 EMPTY_RETURN_CHECK (ComplexMatrix); | 3346 EMPTY_RETURN_CHECK (ComplexMatrix); |
3347 | 3347 |
3348 ComplexMatrix result (nr, nc); | 3348 ComplexMatrix result (nr, nc); |
3349 | 3349 |
3350 for (int j = 0; j < nc; j++) | 3350 for (octave_idx_type j = 0; j < nc; j++) |
3351 for (int i = 0; i < nr; i++) | 3351 for (octave_idx_type i = 0; i < nr; i++) |
3352 { | 3352 { |
3353 OCTAVE_QUIT; | 3353 OCTAVE_QUIT; |
3354 result (i, j) = xmax (c, m (i, j)); | 3354 result (i, j) = xmax (c, m (i, j)); |
3355 } | 3355 } |
3356 | 3356 |
3358 } | 3358 } |
3359 | 3359 |
3360 ComplexMatrix | 3360 ComplexMatrix |
3361 max (const ComplexMatrix& m, const Complex& c) | 3361 max (const ComplexMatrix& m, const Complex& c) |
3362 { | 3362 { |
3363 int nr = m.rows (); | 3363 octave_idx_type nr = m.rows (); |
3364 int nc = m.columns (); | 3364 octave_idx_type nc = m.columns (); |
3365 | 3365 |
3366 EMPTY_RETURN_CHECK (ComplexMatrix); | 3366 EMPTY_RETURN_CHECK (ComplexMatrix); |
3367 | 3367 |
3368 ComplexMatrix result (nr, nc); | 3368 ComplexMatrix result (nr, nc); |
3369 | 3369 |
3370 for (int j = 0; j < nc; j++) | 3370 for (octave_idx_type j = 0; j < nc; j++) |
3371 for (int i = 0; i < nr; i++) | 3371 for (octave_idx_type i = 0; i < nr; i++) |
3372 { | 3372 { |
3373 OCTAVE_QUIT; | 3373 OCTAVE_QUIT; |
3374 result (i, j) = xmax (m (i, j), c); | 3374 result (i, j) = xmax (m (i, j), c); |
3375 } | 3375 } |
3376 | 3376 |
3378 } | 3378 } |
3379 | 3379 |
3380 ComplexMatrix | 3380 ComplexMatrix |
3381 max (const ComplexMatrix& a, const ComplexMatrix& b) | 3381 max (const ComplexMatrix& a, const ComplexMatrix& b) |
3382 { | 3382 { |
3383 int nr = a.rows (); | 3383 octave_idx_type nr = a.rows (); |
3384 int nc = a.columns (); | 3384 octave_idx_type nc = a.columns (); |
3385 | 3385 |
3386 if (nr != b.rows () || nc != b.columns ()) | 3386 if (nr != b.rows () || nc != b.columns ()) |
3387 { | 3387 { |
3388 (*current_liboctave_error_handler) | 3388 (*current_liboctave_error_handler) |
3389 ("two-arg max expecting args of same size"); | 3389 ("two-arg max expecting args of same size"); |
3392 | 3392 |
3393 EMPTY_RETURN_CHECK (ComplexMatrix); | 3393 EMPTY_RETURN_CHECK (ComplexMatrix); |
3394 | 3394 |
3395 ComplexMatrix result (nr, nc); | 3395 ComplexMatrix result (nr, nc); |
3396 | 3396 |
3397 for (int j = 0; j < nc; j++) | 3397 for (octave_idx_type j = 0; j < nc; j++) |
3398 { | 3398 { |
3399 int columns_are_real_only = 1; | 3399 int columns_are_real_only = 1; |
3400 for (int i = 0; i < nr; i++) | 3400 for (octave_idx_type i = 0; i < nr; i++) |
3401 { | 3401 { |
3402 OCTAVE_QUIT; | 3402 OCTAVE_QUIT; |
3403 if (STD_OCTAVE::imag (a (i, j)) != 0.0 || STD_OCTAVE::imag (b (i, j)) != 0.0) | 3403 if (STD_OCTAVE::imag (a (i, j)) != 0.0 || STD_OCTAVE::imag (b (i, j)) != 0.0) |
3404 { | 3404 { |
3405 columns_are_real_only = 0; | 3405 columns_are_real_only = 0; |
3407 } | 3407 } |
3408 } | 3408 } |
3409 | 3409 |
3410 if (columns_are_real_only) | 3410 if (columns_are_real_only) |
3411 { | 3411 { |
3412 for (int i = 0; i < nr; i++) | 3412 for (octave_idx_type i = 0; i < nr; i++) |
3413 { | 3413 { |
3414 OCTAVE_QUIT; | 3414 OCTAVE_QUIT; |
3415 result (i, j) = xmax (STD_OCTAVE::real (a (i, j)), STD_OCTAVE::real (b (i, j))); | 3415 result (i, j) = xmax (STD_OCTAVE::real (a (i, j)), STD_OCTAVE::real (b (i, j))); |
3416 } | 3416 } |
3417 } | 3417 } |
3418 else | 3418 else |
3419 { | 3419 { |
3420 for (int i = 0; i < nr; i++) | 3420 for (octave_idx_type i = 0; i < nr; i++) |
3421 { | 3421 { |
3422 OCTAVE_QUIT; | 3422 OCTAVE_QUIT; |
3423 result (i, j) = xmax (a (i, j), b (i, j)); | 3423 result (i, j) = xmax (a (i, j), b (i, j)); |
3424 } | 3424 } |
3425 } | 3425 } |