26 #if defined (HAVE_CONFIG_H)
59 : q (q_arg),
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 (! q.isempty () && q.issquare ())
79 else if (q.rows () > q.cols () &&
r.issquare ())
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 (q*
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 (q*
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 (q*
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 (q*
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 (! 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 (q*
r, j, u), get_type ());
345 template <
typename T>
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 (q*
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 (q*
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 r.xelem (i, j) = afact.
xelem (i, j);
427 q.xelem (i, j) = afact.
xelem (i, j);
428 afact.
xelem (i, j) = 0;
435 F77_INT k = to_f77_int (q.cols ());
438 F77_XFCN (dorgqr, DORGQR, (
m, k, min_mn, q.fortran_vec (),
m,
439 tau, &rlwork, -1, info));
445 F77_XFCN (dorgqr, DORGQR, (
m, k, min_mn, q.fortran_vec (),
m,
446 tau, work, lwork, info));
485 #if defined (HAVE_QRUPDATE)
493 F77_INT k = to_f77_int (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, q.fortran_vec (),
m,
505 r.fortran_vec (), k, utmp.fortran_vec (),
515 F77_INT k = to_f77_int (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, q.fortran_vec (),
m,
541 F77_INT j = to_f77_int (j_arg);
545 F77_INT k = to_f77_int (q.cols ());
550 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
553 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
563 F77_INT ldq = to_f77_int (q.rows ());
564 F77_INT ldr = to_f77_int (
r.rows ());
568 F77_XFCN (dqrinc, DQRINC, (
m,
n, k, q.fortran_vec (), ldq,
569 r.fortran_vec (), ldr, j + 1,
579 F77_INT k = to_f77_int (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");
609 r.resize (kmax,
n + nj);
612 r.resize (k,
n + nj);
614 F77_INT ldq = to_f77_int (q.rows ());
615 F77_INT ldr = to_f77_int (
r.rows ());
618 for (
volatile F77_INT i = 0; i < nj; i++)
622 F77_INT js_elt = to_f77_int (js(ii));
625 r.fortran_vec (), ldr, js_elt + 1,
635 F77_INT j = to_f77_int (j_arg);
641 if (j < 0 || j >
n-1)
642 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
644 F77_INT ldq = to_f77_int (q.rows ());
645 F77_INT ldr = to_f77_int (
r.rows ());
648 F77_XFCN (dqrdec, DQRDEC, (
m,
n, k, q.fortran_vec (), ldq,
649 r.fortran_vec (), ldr, j + 1,
w));
666 F77_INT k = to_f77_int (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 (q.rows ());
687 F77_INT ldr = to_f77_int (
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 q.fortran_vec (), ldq,
696 r.fortran_vec (), ldr,
702 q.resize (
m, k - nj);
703 r.resize (k - nj,
n - nj);
706 r.resize (k,
n - nj);
714 F77_INT j = to_f77_int (j_arg);
722 if (! q.issquare () || u_nel !=
n)
723 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
726 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
728 q.resize (
m + 1,
m + 1);
731 F77_INT ldq = to_f77_int (q.rows ());
732 F77_INT ldr = to_f77_int (
r.rows ());
736 F77_XFCN (dqrinr, DQRINR, (
m,
n, q.fortran_vec (), ldq,
737 r.fortran_vec (), ldr,
746 F77_INT j = to_f77_int (j_arg);
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 (q.rows ());
758 F77_INT ldr = to_f77_int (
r.rows ());
761 F77_XFCN (dqrder, DQRDER, (
m,
n, q.fortran_vec (), ldq,
762 r.fortran_vec (), ldr, j + 1,
w));
764 q.resize (
m - 1,
m - 1);
772 F77_INT i = to_f77_int (i_arg);
773 F77_INT j = to_f77_int (j_arg);
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 (q.rows ());
783 F77_INT ldr = to_f77_int (
r.rows ());
787 q.fortran_vec (), ldq,
788 r.fortran_vec (), ldr,
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 r.xelem (i, j) = afact.
xelem (i, j);
841 q.xelem (i, j) = afact.
xelem (i, j);
842 afact.
xelem (i, j) = 0;
849 F77_INT k = to_f77_int (q.cols ());
852 F77_XFCN (sorgqr, SORGQR, (
m, k, min_mn, q.fortran_vec (),
m,
853 tau, &rlwork, -1, info));
859 F77_XFCN (sorgqr, SORGQR, (
m, k, min_mn, q.fortran_vec (),
m,
860 tau, work, lwork, info));
899 #if defined (HAVE_QRUPDATE)
907 F77_INT k = to_f77_int (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, q.fortran_vec (),
m,
919 r.fortran_vec (), k, utmp.fortran_vec (),
929 F77_INT k = to_f77_int (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, q.fortran_vec (),
m,
956 F77_INT j = to_f77_int (j_arg);
960 F77_INT k = to_f77_int (q.cols ());
965 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
968 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
978 F77_INT ldq = to_f77_int (q.rows ());
979 F77_INT ldr = to_f77_int (
r.rows ());
983 F77_XFCN (sqrinc, SQRINC, (
m,
n, k, q.fortran_vec (), ldq,
984 r.fortran_vec (), ldr, j + 1,
995 F77_INT k = to_f77_int (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");
1025 r.resize (kmax,
n + nj);
1028 r.resize (k,
n + nj);
1030 F77_INT ldq = to_f77_int (q.rows ());
1031 F77_INT ldr = to_f77_int (
r.rows ());
1034 for (
volatile F77_INT i = 0; i < nj; i++)
1038 F77_INT js_elt = to_f77_int (js(ii));
1041 r.fortran_vec (), ldr, js_elt + 1,
1051 F77_INT j = to_f77_int (j_arg);
1053 F77_INT m = to_f77_int (q.rows ());
1054 F77_INT k = to_f77_int (
r.rows ());
1057 if (j < 0 || j >
n-1)
1058 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
1060 F77_INT ldq = to_f77_int (q.rows ());
1061 F77_INT ldr = to_f77_int (
r.rows ());
1064 F77_XFCN (sqrdec, SQRDEC, (
m,
n, k, q.fortran_vec (), ldq,
1065 r.fortran_vec (), ldr, j + 1,
w));
1070 r.resize (k-1,
n-1);
1080 F77_INT m = to_f77_int (q.rows ());
1082 F77_INT k = to_f77_int (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 (q.rows ());
1103 F77_INT ldr = to_f77_int (
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 q.fortran_vec (), ldq,
1112 r.fortran_vec (), ldr,
1118 q.resize (
m, k - nj);
1119 r.resize (k - nj,
n - nj);
1122 r.resize (k,
n - nj);
1131 F77_INT j = to_f77_int (j_arg);
1139 if (! q.issquare () || u_nel !=
n)
1140 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
1143 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1145 q.resize (
m + 1,
m + 1);
1146 r.resize (
m + 1,
n);
1148 F77_INT ldq = to_f77_int (q.rows ());
1149 F77_INT ldr = to_f77_int (
r.rows ());
1153 F77_XFCN (sqrinr, SQRINR, (
m,
n, q.fortran_vec (), ldq,
1154 r.fortran_vec (), ldr,
1163 F77_INT j = to_f77_int (j_arg);
1168 if (! 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 (q.rows ());
1175 F77_INT ldr = to_f77_int (
r.rows ());
1178 F77_XFCN (sqrder, SQRDER, (
m,
n, q.fortran_vec (), ldq,
1179 r.fortran_vec (), ldr, j + 1,
1182 q.resize (
m - 1,
m - 1);
1183 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 (q.rows ());
1194 F77_INT k = to_f77_int (
r.rows ());
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 (q.rows ());
1201 F77_INT ldr = to_f77_int (
r.rows ());
1205 q.fortran_vec (), ldq,
1206 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 r.xelem (i, j) = afact.
xelem (i, j);
1257 for (
F77_INT i = j + 1; i <
m; i++)
1259 q.xelem (i, j) = afact.
xelem (i, j);
1260 afact.
xelem (i, j) = 0;
1267 F77_INT k = to_f77_int (q.cols ());
1270 F77_XFCN (zungqr, ZUNGQR, (
m, k, min_mn,
1280 F77_XFCN (zungqr, ZUNGQR, (
m, k, min_mn,
1327 #if defined (HAVE_QRUPDATE)
1334 F77_INT m = to_f77_int (q.rows ());
1336 F77_INT k = to_f77_int (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 (q.rows ());
1361 F77_INT k = to_f77_int (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 (q.rows ());
1396 F77_INT k = to_f77_int (q.cols ());
1401 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
1404 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1409 r.resize (k+1,
n+1);
1414 F77_INT ldq = to_f77_int (q.rows ());
1415 F77_INT ldr = to_f77_int (
r.rows ());
1430 F77_INT m = to_f77_int (q.rows ());
1432 F77_INT k = to_f77_int (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");
1462 r.resize (kmax,
n + nj);
1465 r.resize (k,
n + nj);
1467 F77_INT ldq = to_f77_int (q.rows ());
1468 F77_INT ldr = to_f77_int (
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 (q.rows ());
1494 F77_INT k = to_f77_int (
r.rows ());
1497 if (j < 0 || j >
n-1)
1498 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
1500 F77_INT ldq = to_f77_int (q.rows ());
1501 F77_INT ldr = to_f77_int (
r.rows ());
1511 r.resize (k-1,
n-1);
1521 F77_INT m = to_f77_int (q.rows ());
1523 F77_INT k = to_f77_int (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 (q.rows ());
1544 F77_INT ldr = to_f77_int (
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 q.resize (
m, k - nj);
1561 r.resize (k - nj,
n - nj);
1564 r.resize (k,
n - nj);
1573 F77_INT j = to_f77_int (j_arg);
1581 if (! q.issquare () || u_nel !=
n)
1582 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
1585 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1587 q.resize (
m + 1,
m + 1);
1588 r.resize (
m + 1,
n);
1590 F77_INT ldq = to_f77_int (q.rows ());
1591 F77_INT ldr = to_f77_int (
r.rows ());
1606 F77_INT j = to_f77_int (j_arg);
1611 if (! 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 (q.rows ());
1618 F77_INT ldr = to_f77_int (
r.rows ());
1626 q.resize (
m - 1,
m - 1);
1627 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 (q.rows ());
1639 F77_INT k = to_f77_int (
r.rows ());
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 (q.rows ());
1646 F77_INT ldr = to_f77_int (
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 r.xelem (i, j) = afact.
xelem (i, j);
1703 for (
F77_INT i = j + 1; i <
m; i++)
1705 q.xelem (i, j) = afact.
xelem (i, j);
1706 afact.
xelem (i, j) = 0;
1713 F77_INT k = to_f77_int (q.cols ());
1716 F77_XFCN (cungqr, CUNGQR, (
m, k, min_mn,
1725 F77_XFCN (cungqr, CUNGQR, (
m, k, min_mn,
1769 #if defined (HAVE_QRUPDATE)
1776 F77_INT m = to_f77_int (q.rows ());
1778 F77_INT k = to_f77_int (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 (q.rows ());
1804 F77_INT k = to_f77_int (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 (q.rows ());
1838 F77_INT k = to_f77_int (q.cols ());
1843 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
1846 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
1851 r.resize (k+1,
n+1);
1856 F77_INT ldq = to_f77_int (q.rows ());
1857 F77_INT ldr = to_f77_int (
r.rows ());
1871 F77_INT m = to_f77_int (q.rows ());
1873 F77_INT k = to_f77_int (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");
1903 r.resize (kmax,
n + nj);
1906 r.resize (k,
n + nj);
1908 F77_INT ldq = to_f77_int (q.rows ());
1909 F77_INT ldr = to_f77_int (
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 (q.rows ());
1933 F77_INT k = to_f77_int (
r.rows ());
1936 if (j < 0 || j >
n-1)
1937 (*current_liboctave_error_handler) (
"qrdelete: index out of range");
1939 F77_INT ldq = to_f77_int (q.rows ());
1940 F77_INT ldr = to_f77_int (
r.rows ());
1950 r.resize (k-1,
n-1);
1960 F77_INT m = to_f77_int (q.rows ());
1962 F77_INT k = to_f77_int (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 (q.rows ());
1983 F77_INT ldr = to_f77_int (
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 q.resize (
m, k - nj);
1999 r.resize (k - nj,
n - nj);
2002 r.resize (k,
n - nj);
2011 F77_INT j = to_f77_int (j_arg);
2019 if (! q.issquare () || u_nel !=
n)
2020 (*current_liboctave_error_handler) (
"qrinsert: dimensions mismatch");
2023 (*current_liboctave_error_handler) (
"qrinsert: index out of range");
2025 q.resize (
m + 1,
m + 1);
2026 r.resize (
m + 1,
n);
2028 F77_INT ldq = to_f77_int (q.rows ());
2029 F77_INT ldr = to_f77_int (
r.rows ());
2044 F77_INT j = to_f77_int (j_arg);
2049 if (! 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 (q.rows ());
2056 F77_INT ldr = to_f77_int (
r.rows ());
2064 q.resize (
m - 1,
m - 1);
2065 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 (q.rows ());
2077 F77_INT k = to_f77_int (
r.rows ());
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 (q.rows ());
2084 F77_INT ldr = to_f77_int (
r.rows ());
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
Array< T > sort(int dim=0, sortmode mode=ASCENDING) const
Size of the specified dimension.
void assign(const idx_vector &i, const Array< T > &rhs, const T &rfv)
Indexed assignment (always with resize & fill).
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
T & elem(octave_idx_type n)
Size of the specified dimension.
const T * data(void) const
Size of the specified dimension.
octave_idx_type cols(void) const
octave_idx_type rows(void) const
Array< T > column(octave_idx_type k) const
Extract column: A(:,k+1).
const T * fortran_vec(void) const
Size of the specified dimension.
void delete_elements(const idx_vector &i)
Deleting elements.
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 update(const CV_T &u, const CV_T &v)
void init(const T &a, type qr_type)
void insert_row(const RV_T &u, octave_idx_type j)
void insert_col(const CV_T &u, octave_idx_type j)
type get_type(void) const
void shift_cols(octave_idx_type i, octave_idx_type j)
void delete_col(octave_idx_type j)
void form(octave_idx_type n, T &afact, ELT_T *tau, type qr_type)
void delete_row(octave_idx_type j)
#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)
static octave::math::qr< T >::type qr_type(int nargout, bool economy)
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)
void warn_qrupdate_once(void)
std::complex< double > Complex
std::complex< float > FloatComplex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
octave_value::octave_value(const Array< char > &chm, char type) return retval