Mercurial > hg > octave-nkf
comparison liboctave/floatQR.cc @ 11586:12df7854fa7c
strip trailing whitespace from source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:24:59 -0500 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
comparison
equal
deleted
inserted
replaced
11585:1473d0cf86d2 | 11586:12df7854fa7c |
---|---|
40 extern "C" | 40 extern "C" |
41 { | 41 { |
42 F77_RET_T | 42 F77_RET_T |
43 F77_FUNC (sgeqrf, SGEQRF) (const octave_idx_type&, const octave_idx_type&, | 43 F77_FUNC (sgeqrf, SGEQRF) (const octave_idx_type&, const octave_idx_type&, |
44 float*, const octave_idx_type&, float*, float*, | 44 float*, const octave_idx_type&, float*, float*, |
45 const octave_idx_type&, octave_idx_type&); | 45 const octave_idx_type&, octave_idx_type&); |
46 | 46 |
47 F77_RET_T | 47 F77_RET_T |
48 F77_FUNC (sorgqr, SORGQR) (const octave_idx_type&, const octave_idx_type&, | 48 F77_FUNC (sorgqr, SORGQR) (const octave_idx_type&, const octave_idx_type&, |
49 const octave_idx_type&, float*, | 49 const octave_idx_type&, float*, |
50 const octave_idx_type&, float*, float*, | 50 const octave_idx_type&, float*, float*, |
71 const octave_idx_type&, float*, | 71 const octave_idx_type&, float*, |
72 const octave_idx_type&, | 72 const octave_idx_type&, |
73 const octave_idx_type&, float*); | 73 const octave_idx_type&, float*); |
74 | 74 |
75 F77_RET_T | 75 F77_RET_T |
76 F77_FUNC (sqrinr, SQRINR) (const octave_idx_type&, const octave_idx_type&, | 76 F77_FUNC (sqrinr, SQRINR) (const octave_idx_type&, const octave_idx_type&, |
77 float*, const octave_idx_type&, | 77 float*, const octave_idx_type&, |
78 float*, const octave_idx_type&, | 78 float*, const octave_idx_type&, |
79 const octave_idx_type&, const float*, float*); | 79 const octave_idx_type&, const float*, float*); |
80 | 80 |
81 F77_RET_T | 81 F77_RET_T |
82 F77_FUNC (sqrder, SQRDER) (const octave_idx_type&, const octave_idx_type&, | 82 F77_FUNC (sqrder, SQRDER) (const octave_idx_type&, const octave_idx_type&, |
83 float*, const octave_idx_type&, | 83 float*, const octave_idx_type&, |
84 float*, const octave_idx_type&, | 84 float*, const octave_idx_type&, |
85 const octave_idx_type&, float*); | 85 const octave_idx_type&, float*); |
86 | 86 |
87 F77_RET_T | 87 F77_RET_T |
129 } | 129 } |
130 | 130 |
131 form (n, afact, tau, qr_type); | 131 form (n, afact, tau, qr_type); |
132 } | 132 } |
133 | 133 |
134 void FloatQR::form (octave_idx_type n, FloatMatrix& afact, | 134 void FloatQR::form (octave_idx_type n, FloatMatrix& afact, |
135 float *tau, qr_type_t qr_type) | 135 float *tau, qr_type_t qr_type) |
136 { | 136 { |
137 octave_idx_type m = afact.rows (), min_mn = std::min (m, n); | 137 octave_idx_type m = afact.rows (), min_mn = std::min (m, n); |
138 octave_idx_type info; | 138 octave_idx_type info; |
139 | 139 |
247 octave_idx_type n = r.columns (); | 247 octave_idx_type n = r.columns (); |
248 octave_idx_type k = q.columns (); | 248 octave_idx_type k = q.columns (); |
249 | 249 |
250 if (u.length () != m) | 250 if (u.length () != m) |
251 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); | 251 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); |
252 else if (j < 0 || j > n) | 252 else if (j < 0 || j > n) |
253 (*current_liboctave_error_handler) ("qrinsert: index out of range"); | 253 (*current_liboctave_error_handler) ("qrinsert: index out of range"); |
254 else | 254 else |
255 { | 255 { |
256 if (k < m) | 256 if (k < m) |
257 { | 257 { |
264 } | 264 } |
265 | 265 |
266 FloatColumnVector utmp = u; | 266 FloatColumnVector utmp = u; |
267 OCTAVE_LOCAL_BUFFER (float, w, k); | 267 OCTAVE_LOCAL_BUFFER (float, w, k); |
268 F77_XFCN (sqrinc, SQRINC, (m, n, k, q.fortran_vec (), q.rows (), | 268 F77_XFCN (sqrinc, SQRINC, (m, n, k, q.fortran_vec (), q.rows (), |
269 r.fortran_vec (), r.rows (), j + 1, | 269 r.fortran_vec (), r.rows (), j + 1, |
270 utmp.data (), w)); | 270 utmp.data (), w)); |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 void | 274 void |
307 OCTAVE_LOCAL_BUFFER (float, w, kmax); | 307 OCTAVE_LOCAL_BUFFER (float, w, kmax); |
308 for (volatile octave_idx_type i = 0; i < js.length (); i++) | 308 for (volatile octave_idx_type i = 0; i < js.length (); i++) |
309 { | 309 { |
310 octave_idx_type ii = i; | 310 octave_idx_type ii = i; |
311 FloatColumnVector utmp = u.column (jsi(i)); | 311 FloatColumnVector utmp = u.column (jsi(i)); |
312 F77_XFCN (sqrinc, SQRINC, (m, n + ii, std::min (kmax, k + ii), | 312 F77_XFCN (sqrinc, SQRINC, (m, n + ii, std::min (kmax, k + ii), |
313 q.fortran_vec (), q.rows (), | 313 q.fortran_vec (), q.rows (), |
314 r.fortran_vec (), r.rows (), js(ii) + 1, | 314 r.fortran_vec (), r.rows (), js(ii) + 1, |
315 utmp.data (), w)); | 315 utmp.data (), w)); |
316 } | 316 } |
317 } | 317 } |
318 } | 318 } |
319 | 319 |
322 { | 322 { |
323 octave_idx_type m = q.rows (); | 323 octave_idx_type m = q.rows (); |
324 octave_idx_type k = r.rows (); | 324 octave_idx_type k = r.rows (); |
325 octave_idx_type n = r.columns (); | 325 octave_idx_type n = r.columns (); |
326 | 326 |
327 if (j < 0 || j > n-1) | 327 if (j < 0 || j > n-1) |
328 (*current_liboctave_error_handler) ("qrdelete: index out of range"); | 328 (*current_liboctave_error_handler) ("qrdelete: index out of range"); |
329 else | 329 else |
330 { | 330 { |
331 OCTAVE_LOCAL_BUFFER (float, w, k); | 331 OCTAVE_LOCAL_BUFFER (float, w, k); |
332 F77_XFCN (sqrdec, SQRDEC, (m, n, k, q.fortran_vec (), q.rows (), | 332 F77_XFCN (sqrdec, SQRDEC, (m, n, k, q.fortran_vec (), q.rows (), |
366 { | 366 { |
367 OCTAVE_LOCAL_BUFFER (float, w, k); | 367 OCTAVE_LOCAL_BUFFER (float, w, k); |
368 for (volatile octave_idx_type i = 0; i < js.length (); i++) | 368 for (volatile octave_idx_type i = 0; i < js.length (); i++) |
369 { | 369 { |
370 octave_idx_type ii = i; | 370 octave_idx_type ii = i; |
371 F77_XFCN (sqrdec, SQRDEC, (m, n - ii, k == m ? k : k - ii, | 371 F77_XFCN (sqrdec, SQRDEC, (m, n - ii, k == m ? k : k - ii, |
372 q.fortran_vec (), q.rows (), | 372 q.fortran_vec (), q.rows (), |
373 r.fortran_vec (), r.rows (), js(ii) + 1, w)); | 373 r.fortran_vec (), r.rows (), js(ii) + 1, w)); |
374 } | 374 } |
375 if (k < m) | 375 if (k < m) |
376 { | 376 { |
392 octave_idx_type n = r.columns (); | 392 octave_idx_type n = r.columns (); |
393 octave_idx_type k = std::min (m, n); | 393 octave_idx_type k = std::min (m, n); |
394 | 394 |
395 if (! q.is_square () || u.length () != n) | 395 if (! q.is_square () || u.length () != n) |
396 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); | 396 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); |
397 else if (j < 0 || j > m) | 397 else if (j < 0 || j > m) |
398 (*current_liboctave_error_handler) ("qrinsert: index out of range"); | 398 (*current_liboctave_error_handler) ("qrinsert: index out of range"); |
399 else | 399 else |
400 { | 400 { |
401 q.resize (m + 1, m + 1); | 401 q.resize (m + 1, m + 1); |
402 r.resize (m + 1, n); | 402 r.resize (m + 1, n); |
403 FloatRowVector utmp = u; | 403 FloatRowVector utmp = u; |
404 OCTAVE_LOCAL_BUFFER (float, w, k); | 404 OCTAVE_LOCAL_BUFFER (float, w, k); |
405 F77_XFCN (sqrinr, SQRINR, (m, n, q.fortran_vec (), q.rows (), | 405 F77_XFCN (sqrinr, SQRINR, (m, n, q.fortran_vec (), q.rows (), |
406 r.fortran_vec (), r.rows (), | 406 r.fortran_vec (), r.rows (), |
407 j + 1, utmp.fortran_vec (), w)); | 407 j + 1, utmp.fortran_vec (), w)); |
408 | 408 |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
415 octave_idx_type m = r.rows (); | 415 octave_idx_type m = r.rows (); |
416 octave_idx_type n = r.columns (); | 416 octave_idx_type n = r.columns (); |
417 | 417 |
418 if (! q.is_square ()) | 418 if (! q.is_square ()) |
419 (*current_liboctave_error_handler) ("qrdelete: dimensions mismatch"); | 419 (*current_liboctave_error_handler) ("qrdelete: dimensions mismatch"); |
420 else if (j < 0 || j > m-1) | 420 else if (j < 0 || j > m-1) |
421 (*current_liboctave_error_handler) ("qrdelete: index out of range"); | 421 (*current_liboctave_error_handler) ("qrdelete: index out of range"); |
422 else | 422 else |
423 { | 423 { |
424 OCTAVE_LOCAL_BUFFER (float, w, 2*m); | 424 OCTAVE_LOCAL_BUFFER (float, w, 2*m); |
425 F77_XFCN (sqrder, SQRDER, (m, n, q.fortran_vec (), q.rows (), | 425 F77_XFCN (sqrder, SQRDER, (m, n, q.fortran_vec (), q.rows (), |
436 { | 436 { |
437 octave_idx_type m = q.rows (); | 437 octave_idx_type m = q.rows (); |
438 octave_idx_type k = r.rows (); | 438 octave_idx_type k = r.rows (); |
439 octave_idx_type n = r.columns (); | 439 octave_idx_type n = r.columns (); |
440 | 440 |
441 if (i < 0 || i > n-1 || j < 0 || j > n-1) | 441 if (i < 0 || i > n-1 || j < 0 || j > n-1) |
442 (*current_liboctave_error_handler) ("qrshift: index out of range"); | 442 (*current_liboctave_error_handler) ("qrshift: index out of range"); |
443 else | 443 else |
444 { | 444 { |
445 OCTAVE_LOCAL_BUFFER (float, w, 2*k); | 445 OCTAVE_LOCAL_BUFFER (float, w, 2*k); |
446 F77_XFCN (sqrshc, SQRSHC, (m, n, k, | 446 F77_XFCN (sqrshc, SQRSHC, (m, n, k, |
447 q.fortran_vec (), q.rows (), | 447 q.fortran_vec (), q.rows (), |
448 r.fortran_vec (), r.rows (), | 448 r.fortran_vec (), r.rows (), |
449 i + 1, j + 1, w)); | 449 i + 1, j + 1, w)); |
450 } | 450 } |
451 } | 451 } |
527 retval.delete_elements (0, idx_vector (i)); | 527 retval.delete_elements (0, idx_vector (i)); |
528 return retval; | 528 return retval; |
529 } | 529 } |
530 | 530 |
531 static | 531 static |
532 FloatMatrix shift_cols (const FloatMatrix& a, | 532 FloatMatrix shift_cols (const FloatMatrix& a, |
533 octave_idx_type i, octave_idx_type j) | 533 octave_idx_type i, octave_idx_type j) |
534 { | 534 { |
535 octave_idx_type n = a.columns (); | 535 octave_idx_type n = a.columns (); |
536 Array<octave_idx_type> p (n); | 536 Array<octave_idx_type> p (n); |
537 for (octave_idx_type k = 0; k < n; k++) p(k) = k; | 537 for (octave_idx_type k = 0; k < n; k++) p(k) = k; |
557 octave_idx_type m = q.rows (); | 557 octave_idx_type m = q.rows (); |
558 octave_idx_type n = r.columns (); | 558 octave_idx_type n = r.columns (); |
559 | 559 |
560 if (u.length () != m) | 560 if (u.length () != m) |
561 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); | 561 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); |
562 else if (j < 0 || j > n) | 562 else if (j < 0 || j > n) |
563 (*current_liboctave_error_handler) ("qrinsert: index out of range"); | 563 (*current_liboctave_error_handler) ("qrinsert: index out of range"); |
564 else | 564 else |
565 { | 565 { |
566 init (::insert_col (q*r, j, u), get_type ()); | 566 init (::insert_col (q*r, j, u), get_type ()); |
567 } | 567 } |
603 warn_qrupdate_once (); | 603 warn_qrupdate_once (); |
604 | 604 |
605 octave_idx_type m = q.rows (); | 605 octave_idx_type m = q.rows (); |
606 octave_idx_type n = r.columns (); | 606 octave_idx_type n = r.columns (); |
607 | 607 |
608 if (j < 0 || j > n-1) | 608 if (j < 0 || j > n-1) |
609 (*current_liboctave_error_handler) ("qrdelete: index out of range"); | 609 (*current_liboctave_error_handler) ("qrdelete: index out of range"); |
610 else | 610 else |
611 { | 611 { |
612 init (::delete_col (q*r, j), get_type ()); | 612 init (::delete_col (q*r, j), get_type ()); |
613 } | 613 } |
649 octave_idx_type m = r.rows (); | 649 octave_idx_type m = r.rows (); |
650 octave_idx_type n = r.columns (); | 650 octave_idx_type n = r.columns (); |
651 | 651 |
652 if (! q.is_square () || u.length () != n) | 652 if (! q.is_square () || u.length () != n) |
653 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); | 653 (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch"); |
654 else if (j < 0 || j > m) | 654 else if (j < 0 || j > m) |
655 (*current_liboctave_error_handler) ("qrinsert: index out of range"); | 655 (*current_liboctave_error_handler) ("qrinsert: index out of range"); |
656 else | 656 else |
657 { | 657 { |
658 init (::insert_row (q*r, j, u), get_type ()); | 658 init (::insert_row (q*r, j, u), get_type ()); |
659 } | 659 } |
667 octave_idx_type m = r.rows (); | 667 octave_idx_type m = r.rows (); |
668 octave_idx_type n = r.columns (); | 668 octave_idx_type n = r.columns (); |
669 | 669 |
670 if (! q.is_square ()) | 670 if (! q.is_square ()) |
671 (*current_liboctave_error_handler) ("qrdelete: dimensions mismatch"); | 671 (*current_liboctave_error_handler) ("qrdelete: dimensions mismatch"); |
672 else if (j < 0 || j > m-1) | 672 else if (j < 0 || j > m-1) |
673 (*current_liboctave_error_handler) ("qrdelete: index out of range"); | 673 (*current_liboctave_error_handler) ("qrdelete: index out of range"); |
674 else | 674 else |
675 { | 675 { |
676 init (::delete_row (q*r, j), get_type ()); | 676 init (::delete_row (q*r, j), get_type ()); |
677 } | 677 } |
683 warn_qrupdate_once (); | 683 warn_qrupdate_once (); |
684 | 684 |
685 octave_idx_type m = q.rows (); | 685 octave_idx_type m = q.rows (); |
686 octave_idx_type n = r.columns (); | 686 octave_idx_type n = r.columns (); |
687 | 687 |
688 if (i < 0 || i > n-1 || j < 0 || j > n-1) | 688 if (i < 0 || i > n-1 || j < 0 || j > n-1) |
689 (*current_liboctave_error_handler) ("qrshift: index out of range"); | 689 (*current_liboctave_error_handler) ("qrshift: index out of range"); |
690 else | 690 else |
691 { | 691 { |
692 init (::shift_cols (q*r, i, j), get_type ()); | 692 init (::shift_cols (q*r, i, j), get_type ()); |
693 } | 693 } |