26 #if defined (HAVE_CONFIG_H)
59 : m_q (q_arg), m_r (r_arg)
67 if (! (q_nc == r_nr && (q_nr == q_nc || (q_nr > q_nc && r_nr == r_nc))))
68 (*current_liboctave_error_handler) (
"QR dimensions mismatch");
77 if (! m_q.isempty () && m_q.issquare ())
79 else if (m_q.rows () > m_q.cols () && m_r.issquare ())
97 if (m_r(i, i) ==
ELT_T ())
107 #if ! defined (HAVE_QRUPDATE)
114 static bool warned =
false;
118 (*current_liboctave_warning_with_id_handler)
119 (
"Octave:missing-dependency",
120 "In this version of Octave, QR & Cholesky updating routines "
121 "simply update the matrix and recalculate factorizations. "
122 "To use fast algorithms, link Octave with the qrupdate library. "
123 "See <http://sourceforge.net/projects/qrupdate>.");
129 template <
typename T>
138 if (u.numel () !=
m || v.numel () !=
n)
139 (*current_liboctave_error_handler) (
"qrupdate: dimensions mismatch");
141 init (m_q*m_r + T (u) * T (v).hermitian (), get_type ());
144 template <
typename T>
153 if (u.rows () !=
m || v.rows () !=
n || u.cols () != v.cols ())
154 (*current_liboctave_error_handler) (
"qrupdate: dimensions mismatch");
156 init (m_q*m_r + u * v.hermitian (), get_type ());
159 template <
typename T,
typename CV_T>
164 T retval (a.rows (), a.cols () + 1);
173 template <
typename T,
typename RV_T>
178 T retval (a.rows () + 1, a.cols ());
187 template <
typename T>
197 template <
typename T>
207 template <
typename T>
229 template <
typename T>
239 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
242 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
244 init (math::insert_col (m_q*m_r, j, u), get_type ());
247 template <
typename T>
261 dups = dups && js(i) == js(i+1);
264 (*current_liboctave_error_handler) (
"qrinsert: duplicate index detected");
266 if (u.numel () !=
m || u.cols () != nj)
269 if (nj > 0 && (js(0) < 0 || js(nj-1) >
n))
270 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
276 a = math::insert_col (a, js(i), u.
column (i));
278 init (a, get_type ());
282 template <
typename T>
290 if (j < 0 || j >
n-1)
291 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
293 init (math::delete_col (m_q*m_r, j), get_type ());
296 template <
typename T>
309 dups = dups && js(i) == js(i+1);
312 (*current_liboctave_error_handler) (
"qrinsert: duplicate index detected");
314 if (nj > 0 && (js(0) >
n-1 || js(nj-1) < 0))
321 a = math::delete_col (a, js(i));
323 init (a, get_type ());
327 template <
typename T>
336 if (! m_q.issquare () || u.numel () !=
n)
337 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
340 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
342 init (math::insert_row (m_q*m_r, j, u), get_type ());
345 template <
typename T>
353 if (! m_q.issquare ())
354 (*current_liboctave_error_handler) (
"qrdelete: dimensions mismatch");
356 if (j < 0 || j >
m-1)
357 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
359 init (math::delete_row (m_q*m_r, j), get_type ());
362 template <
typename T>
370 if (i < 0 || i >
n-1 || j < 0 || j >
n-1)
371 (*current_liboctave_error_handler) (
"qrshift: index out of range");
373 init (math::shift_cols (m_q*m_r, i, j), get_type ());
392 for (
F77_INT j = 0; j < min_mn; j++)
394 F77_INT limit = (j < min_mn - 1 ? j : min_mn - 1);
395 for (
F77_INT i = limit + 1; i <
m; i++)
396 afact.
elem (i, j) *= tau[j];
414 m_r.xelem (i, j) = afact.
xelem (i, j);
416 m_r.xelem (i, j) = 0;
427 m_q.xelem (i, j) = afact.
xelem (i, j);
428 afact.
xelem (i, j) = 0;
435 F77_INT k = to_f77_int (m_q.cols ());
438 F77_XFCN (dorgqr, DORGQR, (
m, k, min_mn, m_q.fortran_vec (),
m,
439 tau, &rlwork, -1, info));
445 F77_XFCN (dorgqr, DORGQR, (
m, k, min_mn, m_q.fortran_vec (),
m,
446 tau, work, lwork, info));
482 form (
n, afact, tau, qr_type);
485 #if defined (HAVE_QRUPDATE)
491 F77_INT m = to_f77_int (m_q.rows ());
492 F77_INT n = to_f77_int (m_r.cols ());
493 F77_INT k = to_f77_int (m_q.cols ());
498 if (u_nel !=
m || v_nel !=
n)
499 (*current_liboctave_error_handler) (
"qrupdate: dimensions mismatch");
504 F77_XFCN (dqr1up, DQR1UP, (
m,
n, k, m_q.fortran_vec (),
m,
505 m_r.fortran_vec (), k, utmp.fortran_vec (),
513 F77_INT m = to_f77_int (m_q.rows ());
514 F77_INT n = to_f77_int (m_r.cols ());
515 F77_INT k = to_f77_int (m_q.cols ());
523 if (u_rows !=
m || v_rows !=
n || u_cols != v_cols)
524 (*current_liboctave_error_handler) (
"qrupdate: dimensions mismatch");
527 for (
volatile F77_INT i = 0; i < u_cols; i++)
531 F77_XFCN (dqr1up, DQR1UP, (
m,
n, k, m_q.fortran_vec (),
m,
541 F77_INT j = to_f77_int (j_arg);
543 F77_INT m = to_f77_int (m_q.rows ());
544 F77_INT n = to_f77_int (m_r.cols ());
545 F77_INT k = to_f77_int (m_q.cols ());
550 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
553 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
558 m_r.resize (k+1,
n+1);
563 F77_INT ldq = to_f77_int (m_q.rows ());
564 F77_INT ldr = to_f77_int (m_r.rows ());
568 F77_XFCN (dqrinc, DQRINC, (
m,
n, k, m_q.fortran_vec (), ldq,
569 m_r.fortran_vec (), ldr, j + 1,
577 F77_INT m = to_f77_int (m_q.rows ());
578 F77_INT n = to_f77_int (m_r.cols ());
579 F77_INT k = to_f77_int (m_q.cols ());
585 for (
F77_INT i = 0; i < nj - 1; i++)
586 dups = dups && js(i) == js(i+1);
589 (*current_liboctave_error_handler) (
"qrinsert: duplicate index detected");
594 if (u_nel !=
m || u_cols != nj)
595 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
597 F77_INT js_beg = to_f77_int (js(0));
598 F77_INT js_end = to_f77_int (js(nj-1));
600 if (nj > 0 && (js_beg < 0 || js_end >
n))
601 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
608 m_q.resize (
m, kmax);
609 m_r.resize (kmax,
n + nj);
612 m_r.resize (k,
n + nj);
614 F77_INT ldq = to_f77_int (m_q.rows ());
615 F77_INT ldr = to_f77_int (m_r.rows ());
618 for (
volatile F77_INT i = 0; i < nj; i++)
622 F77_INT js_elt = to_f77_int (js(ii));
625 m_r.fortran_vec (), ldr, js_elt + 1,
635 F77_INT j = to_f77_int (j_arg);
637 F77_INT m = to_f77_int (m_q.rows ());
638 F77_INT k = to_f77_int (m_r.rows ());
639 F77_INT n = to_f77_int (m_r.cols ());
641 if (j < 0 || j >
n-1)
642 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
644 F77_INT ldq = to_f77_int (m_q.rows ());
645 F77_INT ldr = to_f77_int (m_r.rows ());
648 F77_XFCN (dqrdec, DQRDEC, (
m,
n, k, m_q.fortran_vec (), ldq,
649 m_r.fortran_vec (), ldr, j + 1,
w));
654 m_r.resize (k-1,
n-1);
664 F77_INT m = to_f77_int (m_q.rows ());
665 F77_INT n = to_f77_int (m_r.cols ());
666 F77_INT k = to_f77_int (m_q.cols ());
672 for (
F77_INT i = 0; i < nj - 1; i++)
673 dups = dups && js(i) == js(i+1);
676 (*current_liboctave_error_handler) (
"qrinsert: duplicate index detected");
678 F77_INT js_beg = to_f77_int (js(0));
679 F77_INT js_end = to_f77_int (js(nj-1));
681 if (nj > 0 && (js_beg >
n-1 || js_end < 0))
682 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
686 F77_INT ldq = to_f77_int (m_q.rows ());
687 F77_INT ldr = to_f77_int (m_r.rows ());
690 for (
volatile F77_INT i = 0; i < nj; i++)
693 F77_INT js_elt = to_f77_int (js(ii));
694 F77_XFCN (dqrdec, DQRDEC, (
m,
n - ii, (k ==
m ? k : k - ii),
695 m_q.fortran_vec (), ldq,
696 m_r.fortran_vec (), ldr,
702 m_q.resize (
m, k - nj);
703 m_r.resize (k - nj,
n - nj);
706 m_r.resize (k,
n - nj);
714 F77_INT j = to_f77_int (j_arg);
716 F77_INT m = to_f77_int (m_r.rows ());
717 F77_INT n = to_f77_int (m_r.cols ());
722 if (! m_q.issquare () || u_nel !=
n)
723 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
726 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
728 m_q.resize (
m + 1,
m + 1);
729 m_r.resize (
m + 1,
n);
731 F77_INT ldq = to_f77_int (m_q.rows ());
732 F77_INT ldr = to_f77_int (m_r.rows ());
736 F77_XFCN (dqrinr, DQRINR, (
m,
n, m_q.fortran_vec (), ldq,
737 m_r.fortran_vec (), ldr,
746 F77_INT j = to_f77_int (j_arg);
748 F77_INT m = to_f77_int (m_r.rows ());
749 F77_INT n = to_f77_int (m_r.cols ());
751 if (! m_q.issquare ())
752 (*current_liboctave_error_handler) (
"qrdelete: dimensions mismatch");
754 if (j < 0 || j >
m-1)
755 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
757 F77_INT ldq = to_f77_int (m_q.rows ());
758 F77_INT ldr = to_f77_int (m_r.rows ());
761 F77_XFCN (dqrder, DQRDER, (
m,
n, m_q.fortran_vec (), ldq,
762 m_r.fortran_vec (), ldr, j + 1,
w));
764 m_q.resize (
m - 1,
m - 1);
765 m_r.resize (
m - 1,
n);
772 F77_INT i = to_f77_int (i_arg);
773 F77_INT j = to_f77_int (j_arg);
775 F77_INT m = to_f77_int (m_q.rows ());
776 F77_INT k = to_f77_int (m_r.rows ());
777 F77_INT n = to_f77_int (m_r.cols ());
779 if (i < 0 || i >
n-1 || j < 0 || j >
n-1)
780 (*current_liboctave_error_handler) (
"qrshift: index out of range");
782 F77_INT ldq = to_f77_int (m_q.rows ());
783 F77_INT ldr = to_f77_int (m_r.rows ());
787 m_q.fortran_vec (), ldq,
788 m_r.fortran_vec (), ldr,
797 float *tau,
type qr_type)
806 for (
F77_INT j = 0; j < min_mn; j++)
808 F77_INT limit = (j < min_mn - 1 ? j : min_mn - 1);
809 for (
F77_INT i = limit + 1; i <
m; i++)
810 afact.
elem (i, j) *= tau[j];
828 m_r.xelem (i, j) = afact.
xelem (i, j);
830 m_r.xelem (i, j) = 0;
841 m_q.xelem (i, j) = afact.
xelem (i, j);
842 afact.
xelem (i, j) = 0;
849 F77_INT k = to_f77_int (m_q.cols ());
852 F77_XFCN (sorgqr, SORGQR, (
m, k, min_mn, m_q.fortran_vec (),
m,
853 tau, &rlwork, -1, info));
859 F77_XFCN (sorgqr, SORGQR, (
m, k, min_mn, m_q.fortran_vec (),
m,
860 tau, work, lwork, info));
896 form (
n, afact, tau, qr_type);
899 #if defined (HAVE_QRUPDATE)
905 F77_INT m = to_f77_int (m_q.rows ());
906 F77_INT n = to_f77_int (m_r.cols ());
907 F77_INT k = to_f77_int (m_q.cols ());
912 if (u_nel !=
m || v_nel !=
n)
913 (*current_liboctave_error_handler) (
"qrupdate: dimensions mismatch");
918 F77_XFCN (sqr1up, SQR1UP, (
m,
n, k, m_q.fortran_vec (),
m,
919 m_r.fortran_vec (), k, utmp.fortran_vec (),
927 F77_INT m = to_f77_int (m_q.rows ());
928 F77_INT n = to_f77_int (m_r.cols ());
929 F77_INT k = to_f77_int (m_q.cols ());
937 if (u_rows !=
m || v_rows !=
n || u_cols != v_cols)
938 (*current_liboctave_error_handler) (
"qrupdate: dimensions mismatch");
941 for (
volatile F77_INT i = 0; i < u_cols; i++)
945 F77_XFCN (sqr1up, SQR1UP, (
m,
n, k, m_q.fortran_vec (),
m,
956 F77_INT j = to_f77_int (j_arg);
958 F77_INT m = to_f77_int (m_q.rows ());
959 F77_INT n = to_f77_int (m_r.cols ());
960 F77_INT k = to_f77_int (m_q.cols ());
965 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
968 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
973 m_r.resize (k+1,
n+1);
978 F77_INT ldq = to_f77_int (m_q.rows ());
979 F77_INT ldr = to_f77_int (m_r.rows ());
983 F77_XFCN (sqrinc, SQRINC, (
m,
n, k, m_q.fortran_vec (), ldq,
984 m_r.fortran_vec (), ldr, j + 1,
993 F77_INT m = to_f77_int (m_q.rows ());
994 F77_INT n = to_f77_int (m_r.cols ());
995 F77_INT k = to_f77_int (m_q.cols ());
1001 for (
F77_INT i = 0; i < nj - 1; i++)
1002 dups = dups && js(i) == js(i+1);
1005 (*current_liboctave_error_handler) (
"qrinsert: duplicate index detected");
1010 if (u_nel !=
m || u_cols != nj)
1011 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
1013 F77_INT js_beg = to_f77_int (js(0));
1014 F77_INT js_end = to_f77_int (js(nj-1));
1016 if (nj > 0 && (js_beg < 0 || js_end >
n))
1017 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1024 m_q.resize (
m, kmax);
1025 m_r.resize (kmax,
n + nj);
1028 m_r.resize (k,
n + nj);
1030 F77_INT ldq = to_f77_int (m_q.rows ());
1031 F77_INT ldr = to_f77_int (m_r.rows ());
1034 for (
volatile F77_INT i = 0; i < nj; i++)
1038 F77_INT js_elt = to_f77_int (js(ii));
1041 m_r.fortran_vec (), ldr, js_elt + 1,
1051 F77_INT j = to_f77_int (j_arg);
1053 F77_INT m = to_f77_int (m_q.rows ());
1054 F77_INT k = to_f77_int (m_r.rows ());
1055 F77_INT n = to_f77_int (m_r.cols ());
1057 if (j < 0 || j >
n-1)
1058 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
1060 F77_INT ldq = to_f77_int (m_q.rows ());
1061 F77_INT ldr = to_f77_int (m_r.rows ());
1064 F77_XFCN (sqrdec, SQRDEC, (
m,
n, k, m_q.fortran_vec (), ldq,
1065 m_r.fortran_vec (), ldr, j + 1,
w));
1069 m_q.resize (
m, k-1);
1070 m_r.resize (k-1,
n-1);
1073 m_r.resize (k,
n-1);
1080 F77_INT m = to_f77_int (m_q.rows ());
1081 F77_INT n = to_f77_int (m_r.cols ());
1082 F77_INT k = to_f77_int (m_q.cols ());
1088 for (
F77_INT i = 0; i < nj - 1; i++)
1089 dups = dups && js(i) == js(i+1);
1092 (*current_liboctave_error_handler) (
"qrinsert: duplicate index detected");
1094 F77_INT js_beg = to_f77_int (js(0));
1095 F77_INT js_end = to_f77_int (js(nj-1));
1097 if (nj > 0 && (js_beg >
n-1 || js_end < 0))
1098 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1102 F77_INT ldq = to_f77_int (m_q.rows ());
1103 F77_INT ldr = to_f77_int (m_r.rows ());
1106 for (
volatile F77_INT i = 0; i < nj; i++)
1109 F77_INT js_elt = to_f77_int (js(ii));
1110 F77_XFCN (sqrdec, SQRDEC, (
m,
n - ii, (k ==
m ? k : k - ii),
1111 m_q.fortran_vec (), ldq,
1112 m_r.fortran_vec (), ldr,
1118 m_q.resize (
m, k - nj);
1119 m_r.resize (k - nj,
n - nj);
1122 m_r.resize (k,
n - nj);
1131 F77_INT j = to_f77_int (j_arg);
1133 F77_INT m = to_f77_int (m_r.rows ());
1134 F77_INT n = to_f77_int (m_r.cols ());
1139 if (! m_q.issquare () || u_nel !=
n)
1140 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
1143 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1145 m_q.resize (
m + 1,
m + 1);
1146 m_r.resize (
m + 1,
n);
1148 F77_INT ldq = to_f77_int (m_q.rows ());
1149 F77_INT ldr = to_f77_int (m_r.rows ());
1153 F77_XFCN (sqrinr, SQRINR, (
m,
n, m_q.fortran_vec (), ldq,
1154 m_r.fortran_vec (), ldr,
1163 F77_INT j = to_f77_int (j_arg);
1165 F77_INT m = to_f77_int (m_r.rows ());
1166 F77_INT n = to_f77_int (m_r.cols ());
1168 if (! m_q.issquare ())
1169 (*current_liboctave_error_handler) (
"qrdelete: dimensions mismatch");
1171 if (j < 0 || j >
m-1)
1172 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
1174 F77_INT ldq = to_f77_int (m_q.rows ());
1175 F77_INT ldr = to_f77_int (m_r.rows ());
1178 F77_XFCN (sqrder, SQRDER, (
m,
n, m_q.fortran_vec (), ldq,
1179 m_r.fortran_vec (), ldr, j + 1,
1182 m_q.resize (
m - 1,
m - 1);
1183 m_r.resize (
m - 1,
n);
1190 F77_INT i = to_f77_int (i_arg);
1191 F77_INT j = to_f77_int (j_arg);
1193 F77_INT m = to_f77_int (m_q.rows ());
1194 F77_INT k = to_f77_int (m_r.rows ());
1195 F77_INT n = to_f77_int (m_r.cols ());
1197 if (i < 0 || i >
n-1 || j < 0 || j >
n-1)
1198 (*current_liboctave_error_handler) (
"qrshift: index out of range");
1200 F77_INT ldq = to_f77_int (m_q.rows ());
1201 F77_INT ldr = to_f77_int (m_r.rows ());
1205 m_q.fortran_vec (), ldq,
1206 m_r.fortran_vec (), ldr,
1224 for (
F77_INT j = 0; j < min_mn; j++)
1226 F77_INT limit = (j < min_mn - 1 ? j : min_mn - 1);
1227 for (
F77_INT i = limit + 1; i <
m; i++)
1228 afact.
elem (i, j) *= tau[j];
1246 m_r.xelem (i, j) = afact.
xelem (i, j);
1248 m_r.xelem (i, j) = 0;
1257 for (
F77_INT i = j + 1; i <
m; i++)
1259 m_q.xelem (i, j) = afact.
xelem (i, j);
1260 afact.
xelem (i, j) = 0;
1267 F77_INT k = to_f77_int (m_q.cols ());
1270 F77_XFCN (zungqr, ZUNGQR, (
m, k, min_mn,
1280 F77_XFCN (zungqr, ZUNGQR, (
m, k, min_mn,
1324 form (
n, afact, tau, qr_type);
1327 #if defined (HAVE_QRUPDATE)
1334 F77_INT m = to_f77_int (m_q.rows ());
1335 F77_INT n = to_f77_int (m_r.cols ());
1336 F77_INT k = to_f77_int (m_q.cols ());
1341 if (u_nel !=
m || v_nel !=
n)
1342 (*current_liboctave_error_handler) (
"qrupdate: dimensions mismatch");
1359 F77_INT m = to_f77_int (m_q.rows ());
1360 F77_INT n = to_f77_int (m_r.cols ());
1361 F77_INT k = to_f77_int (m_q.cols ());
1369 if (u_rows !=
m || v_rows !=
n || u_cols != v_cols)
1370 (*current_liboctave_error_handler) (
"qrupdate: dimensions mismatch");
1374 for (
volatile F77_INT i = 0; i < u_cols; i++)
1392 F77_INT j = to_f77_int (j_arg);
1394 F77_INT m = to_f77_int (m_q.rows ());
1395 F77_INT n = to_f77_int (m_r.cols ());
1396 F77_INT k = to_f77_int (m_q.cols ());
1401 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
1404 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1408 m_q.resize (
m, k+1);
1409 m_r.resize (k+1,
n+1);
1412 m_r.resize (k,
n+1);
1414 F77_INT ldq = to_f77_int (m_q.rows ());
1415 F77_INT ldr = to_f77_int (m_r.rows ());
1430 F77_INT m = to_f77_int (m_q.rows ());
1431 F77_INT n = to_f77_int (m_r.cols ());
1432 F77_INT k = to_f77_int (m_q.cols ());
1438 for (
F77_INT i = 0; i < nj - 1; i++)
1439 dups = dups && js(i) == js(i+1);
1442 (*current_liboctave_error_handler) (
"qrinsert: duplicate index detected");
1447 if (u_nel !=
m || u_cols != nj)
1448 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
1450 F77_INT js_beg = to_f77_int (js(0));
1451 F77_INT js_end = to_f77_int (js(nj-1));
1453 if (nj > 0 && (js_beg < 0 || js_end >
n))
1454 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1461 m_q.resize (
m, kmax);
1462 m_r.resize (kmax,
n + nj);
1465 m_r.resize (k,
n + nj);
1467 F77_INT ldq = to_f77_int (m_q.rows ());
1468 F77_INT ldr = to_f77_int (m_r.rows ());
1471 for (
volatile F77_INT i = 0; i < nj; i++)
1475 F77_INT js_elt = to_f77_int (js(ii));
1491 F77_INT j = to_f77_int (j_arg);
1493 F77_INT m = to_f77_int (m_q.rows ());
1494 F77_INT k = to_f77_int (m_r.rows ());
1495 F77_INT n = to_f77_int (m_r.cols ());
1497 if (j < 0 || j >
n-1)
1498 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
1500 F77_INT ldq = to_f77_int (m_q.rows ());
1501 F77_INT ldr = to_f77_int (m_r.rows ());
1510 m_q.resize (
m, k-1);
1511 m_r.resize (k-1,
n-1);
1514 m_r.resize (k,
n-1);
1521 F77_INT m = to_f77_int (m_q.rows ());
1522 F77_INT n = to_f77_int (m_r.cols ());
1523 F77_INT k = to_f77_int (m_q.cols ());
1529 for (
F77_INT i = 0; i < nj - 1; i++)
1530 dups = dups && js(i) == js(i+1);
1533 (*current_liboctave_error_handler) (
"qrinsert: duplicate index detected");
1535 F77_INT js_beg = to_f77_int (js(0));
1536 F77_INT js_end = to_f77_int (js(nj-1));
1538 if (nj > 0 && (js_beg >
n-1 || js_end < 0))
1539 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1543 F77_INT ldq = to_f77_int (m_q.rows ());
1544 F77_INT ldr = to_f77_int (m_r.rows ());
1547 for (
volatile F77_INT i = 0; i < nj; i++)
1550 F77_INT js_elt = to_f77_int (js(ii));
1551 F77_XFCN (zqrdec, ZQRDEC, (
m,
n - ii, (k ==
m ? k : k - ii),
1555 ldr, js_elt + 1, rw));
1560 m_q.resize (
m, k - nj);
1561 m_r.resize (k - nj,
n - nj);
1564 m_r.resize (k,
n - nj);
1573 F77_INT j = to_f77_int (j_arg);
1575 F77_INT m = to_f77_int (m_r.rows ());
1576 F77_INT n = to_f77_int (m_r.cols ());
1581 if (! m_q.issquare () || u_nel !=
n)
1582 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
1585 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1587 m_q.resize (
m + 1,
m + 1);
1588 m_r.resize (
m + 1,
n);
1590 F77_INT ldq = to_f77_int (m_q.rows ());
1591 F77_INT ldr = to_f77_int (m_r.rows ());
1606 F77_INT j = to_f77_int (j_arg);
1608 F77_INT m = to_f77_int (m_r.rows ());
1609 F77_INT n = to_f77_int (m_r.cols ());
1611 if (! m_q.issquare ())
1612 (*current_liboctave_error_handler) (
"qrdelete: dimensions mismatch");
1614 if (j < 0 || j >
m-1)
1615 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
1617 F77_INT ldq = to_f77_int (m_q.rows ());
1618 F77_INT ldr = to_f77_int (m_r.rows ());
1626 m_q.resize (
m - 1,
m - 1);
1627 m_r.resize (
m - 1,
n);
1635 F77_INT i = to_f77_int (i_arg);
1636 F77_INT j = to_f77_int (j_arg);
1638 F77_INT m = to_f77_int (m_q.rows ());
1639 F77_INT k = to_f77_int (m_r.rows ());
1640 F77_INT n = to_f77_int (m_r.cols ());
1642 if (i < 0 || i >
n-1 || j < 0 || j >
n-1)
1643 (*current_liboctave_error_handler) (
"qrshift: index out of range");
1645 F77_INT ldq = to_f77_int (m_q.rows ());
1646 F77_INT ldr = to_f77_int (m_r.rows ());
1670 for (
F77_INT j = 0; j < min_mn; j++)
1672 F77_INT limit = (j < min_mn - 1 ? j : min_mn - 1);
1673 for (
F77_INT i = limit + 1; i <
m; i++)
1674 afact.
elem (i, j) *= tau[j];
1692 m_r.xelem (i, j) = afact.
xelem (i, j);
1694 m_r.xelem (i, j) = 0;
1703 for (
F77_INT i = j + 1; i <
m; i++)
1705 m_q.xelem (i, j) = afact.
xelem (i, j);
1706 afact.
xelem (i, j) = 0;
1713 F77_INT k = to_f77_int (m_q.cols ());
1716 F77_XFCN (cungqr, CUNGQR, (
m, k, min_mn,
1725 F77_XFCN (cungqr, CUNGQR, (
m, k, min_mn,
1766 form (
n, afact, tau, qr_type);
1769 #if defined (HAVE_QRUPDATE)
1776 F77_INT m = to_f77_int (m_q.rows ());
1777 F77_INT n = to_f77_int (m_r.cols ());
1778 F77_INT k = to_f77_int (m_q.cols ());
1783 if (u_nel !=
m || v_nel !=
n)
1784 (*current_liboctave_error_handler) (
"qrupdate: dimensions mismatch");
1802 F77_INT m = to_f77_int (m_q.rows ());
1803 F77_INT n = to_f77_int (m_r.cols ());
1804 F77_INT k = to_f77_int (m_q.cols ());
1812 if (u_rows !=
m || v_rows !=
n || u_cols != v_cols)
1813 (*current_liboctave_error_handler) (
"qrupdate: dimensions mismatch");
1817 for (
volatile F77_INT i = 0; i < u_cols; i++)
1834 F77_INT j = to_f77_int (j_arg);
1836 F77_INT m = to_f77_int (m_q.rows ());
1837 F77_INT n = to_f77_int (m_r.cols ());
1838 F77_INT k = to_f77_int (m_q.cols ());
1843 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
1846 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1850 m_q.resize (
m, k+1);
1851 m_r.resize (k+1,
n+1);
1854 m_r.resize (k,
n+1);
1856 F77_INT ldq = to_f77_int (m_q.rows ());
1857 F77_INT ldr = to_f77_int (m_r.rows ());
1871 F77_INT m = to_f77_int (m_q.rows ());
1872 F77_INT n = to_f77_int (m_r.cols ());
1873 F77_INT k = to_f77_int (m_q.cols ());
1879 for (
F77_INT i = 0; i < nj - 1; i++)
1880 dups = dups && js(i) == js(i+1);
1883 (*current_liboctave_error_handler) (
"qrinsert: duplicate index detected");
1888 if (u_nel !=
m || u_cols != nj)
1889 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
1891 F77_INT js_beg = to_f77_int (js(0));
1892 F77_INT js_end = to_f77_int (js(nj-1));
1894 if (nj > 0 && (js_beg < 0 || js_end >
n))
1895 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1902 m_q.resize (
m, kmax);
1903 m_r.resize (kmax,
n + nj);
1906 m_r.resize (k,
n + nj);
1908 F77_INT ldq = to_f77_int (m_q.rows ());
1909 F77_INT ldr = to_f77_int (m_r.rows ());
1912 for (
volatile F77_INT i = 0; i < nj; i++)
1915 F77_INT js_elt = to_f77_int (js(ii));
1930 F77_INT j = to_f77_int (j_arg);
1932 F77_INT m = to_f77_int (m_q.rows ());
1933 F77_INT k = to_f77_int (m_r.rows ());
1934 F77_INT n = to_f77_int (m_r.cols ());
1936 if (j < 0 || j >
n-1)
1937 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
1939 F77_INT ldq = to_f77_int (m_q.rows ());
1940 F77_INT ldr = to_f77_int (m_r.rows ());
1949 m_q.resize (
m, k-1);
1950 m_r.resize (k-1,
n-1);
1953 m_r.resize (k,
n-1);
1960 F77_INT m = to_f77_int (m_q.rows ());
1961 F77_INT n = to_f77_int (m_r.cols ());
1962 F77_INT k = to_f77_int (m_q.cols ());
1968 for (
F77_INT i = 0; i < nj - 1; i++)
1969 dups = dups && js(i) == js(i+1);
1972 (*current_liboctave_error_handler) (
"qrinsert: duplicate index detected");
1974 F77_INT js_beg = to_f77_int (js(0));
1975 F77_INT js_end = to_f77_int (js(nj-1));
1977 if (nj > 0 && (js_beg >
n-1 || js_end < 0))
1978 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1982 F77_INT ldq = to_f77_int (m_q.rows ());
1983 F77_INT ldr = to_f77_int (m_r.rows ());
1986 for (
volatile F77_INT i = 0; i < nj; i++)
1989 F77_INT js_elt = to_f77_int (js(ii));
1990 F77_XFCN (cqrdec, CQRDEC, (
m,
n - ii, (k ==
m ? k : k - ii),
1998 m_q.resize (
m, k - nj);
1999 m_r.resize (k - nj,
n - nj);
2002 m_r.resize (k,
n - nj);
2011 F77_INT j = to_f77_int (j_arg);
2013 F77_INT m = to_f77_int (m_r.rows ());
2014 F77_INT n = to_f77_int (m_r.cols ());
2019 if (! m_q.issquare () || u_nel !=
n)
2020 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
2023 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
2025 m_q.resize (
m + 1,
m + 1);
2026 m_r.resize (
m + 1,
n);
2028 F77_INT ldq = to_f77_int (m_q.rows ());
2029 F77_INT ldr = to_f77_int (m_r.rows ());
2044 F77_INT j = to_f77_int (j_arg);
2046 F77_INT m = to_f77_int (m_r.rows ());
2047 F77_INT n = to_f77_int (m_r.cols ());
2049 if (! m_q.issquare ())
2050 (*current_liboctave_error_handler) (
"qrdelete: dimensions mismatch");
2052 if (j < 0 || j >
m-1)
2053 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
2055 F77_INT ldq = to_f77_int (m_q.rows ());
2056 F77_INT ldr = to_f77_int (m_r.rows ());
2064 m_q.resize (
m - 1,
m - 1);
2065 m_r.resize (
m - 1,
n);
2073 F77_INT i = to_f77_int (i_arg);
2074 F77_INT j = to_f77_int (j_arg);
2076 F77_INT m = to_f77_int (m_q.rows ());
2077 F77_INT k = to_f77_int (m_r.rows ());
2078 F77_INT n = to_f77_int (m_r.cols ());
2080 if (i < 0 || i >
n-1 || j < 0 || j >
n-1)
2081 (*current_liboctave_error_handler) (
"qrshift: index out of range");
2083 F77_INT ldq = to_f77_int (m_q.rows ());
2084 F77_INT ldr = to_f77_int (m_r.rows ());
2106 OCTAVE_END_NAMESPACE(math)
2107 OCTAVE_END_NAMESPACE(
octave)
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
T & elem(octave_idx_type n)
Size of the specified dimension.
T * fortran_vec()
Size of the specified dimension.
Array< T, Alloc > column(octave_idx_type k) const
Extract column: A(:,k+1).
octave_idx_type rows() const
const T * data() const
Size of the specified dimension.
octave_idx_type cols() const
Array< T, Alloc > sort(int dim=0, sortmode mode=ASCENDING) const
Size of the specified dimension.
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
void resize(octave_idx_type nr, octave_idx_type nc, const Complex &rfv=Complex(0))
ComplexColumnVector column(octave_idx_type i) const
FloatComplexColumnVector column(octave_idx_type i) const
void resize(octave_idx_type nr, octave_idx_type nc, const FloatComplex &rfv=FloatComplex(0))
void resize(octave_idx_type nr, octave_idx_type nc, float rfv=0)
FloatColumnVector column(octave_idx_type i) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
ColumnVector column(octave_idx_type i) const
Vector representing the dimensions (size) of an Array.
static const idx_vector colon
octave_idx_type index(const T *src, octave_idx_type n, T *dest) const
void insert_row(const RV_T &u, octave_idx_type j)
void delete_row(octave_idx_type j)
void delete_col(octave_idx_type j)
void update(const CV_T &u, const CV_T &v)
void form(octave_idx_type n, T &afact, ELT_T *tau, type qr_type)
void insert_col(const CV_T &u, octave_idx_type j)
void shift_cols(octave_idx_type i, octave_idx_type j)
void init(const T &a, type qr_type)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define F77_CONST_CMPLX_ARG(x)
#define F77_DBLE_CMPLX_ARG(x)
#define F77_XFCN(f, F, args)
octave_f77_int_type F77_INT
#define F77_CONST_DBLE_CMPLX_ARG(x)
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
F77_RET_T const F77_DBLE * x
std::complex< double > w(std::complex< double > z, double relerr=0)
std::complex< double > Complex
std::complex< float > FloatComplex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
void warn_qrupdate_once()