124 return !(*
this == a);
133 if (nr == nc && nr > 0)
186 return max (dummy_idx, dim);
197 if (dim >= dv.
ndims ())
210 if (nr == 0 || nc == 0 || dim >= dv.
ndims ())
216 double tmp_max = octave::numeric_limits<double>::NaN ();
220 if (
ridx (i) != idx_j)
231 double tmp =
data (i);
233 if (octave::math::isnan (tmp))
235 else if (octave::math::isnan (tmp_max) || tmp > tmp_max)
243 idx_arg.
elem (j) = (octave::math::isnan (tmp_max) ? 0 : idx_j);
251 result.
xcidx (0) = 0;
254 double tmp =
elem (idx_arg(j), j);
257 result.
xdata (ii) = tmp;
258 result.
xridx (ii++) = 0;
260 result.
xcidx (j+1) = ii;
268 if (nr == 0 || nc == 0 || dim >= dv.
ndims ())
278 if (found[
ridx (i)] == -j)
279 found[
ridx (i)] = -j - 1;
282 if (found[i] > -nc && found[i] < 0)
283 idx_arg.
elem (i) = -found[i];
291 double tmp =
data (i);
293 if (octave::math::isnan (tmp))
295 else if (ix == -1 || tmp >
elem (ir, ix))
296 idx_arg.
elem (ir) = j;
302 if (idx_arg.
elem (j) == -1 ||
elem (j, idx_arg.
elem (j)) != 0.)
308 result.
xcidx (0) = 0;
309 result.
xcidx (1) = nel;
312 if (idx_arg(j) == -1)
315 result.
xdata (ii) = octave::numeric_limits<double>::NaN ();
316 result.
xridx (ii++) = j;
320 double tmp =
elem (j, idx_arg(j));
323 result.
xdata (ii) = tmp;
324 result.
xridx (ii++) = j;
337 return min (dummy_idx, dim);
348 if (dim >= dv.
ndims ())
361 if (nr == 0 || nc == 0 || dim >= dv.
ndims ())
367 double tmp_min = octave::numeric_limits<double>::NaN ();
371 if (
ridx (i) != idx_j)
382 double tmp =
data (i);
384 if (octave::math::isnan (tmp))
386 else if (octave::math::isnan (tmp_min) || tmp < tmp_min)
394 idx_arg.
elem (j) = (octave::math::isnan (tmp_min) ? 0 : idx_j);
402 result.
xcidx (0) = 0;
405 double tmp =
elem (idx_arg(j), j);
408 result.
xdata (ii) = tmp;
409 result.
xridx (ii++) = 0;
411 result.
xcidx (j+1) = ii;
419 if (nr == 0 || nc == 0 || dim >= dv.
ndims ())
429 if (found[
ridx (i)] == -j)
430 found[
ridx (i)] = -j - 1;
433 if (found[i] > -nc && found[i] < 0)
434 idx_arg.
elem (i) = -found[i];
442 double tmp =
data (i);
444 if (octave::math::isnan (tmp))
446 else if (ix == -1 || tmp <
elem (ir, ix))
447 idx_arg.
elem (ir) = j;
453 if (idx_arg.
elem (j) == -1 ||
elem (j, idx_arg.
elem (j)) != 0.)
459 result.
xcidx (0) = 0;
460 result.
xcidx (1) = nel;
463 if (idx_arg(j) == -1)
466 result.
xdata (ii) = octave::numeric_limits<double>::NaN ();
467 result.
xridx (ii++) = j;
471 double tmp =
elem (j, idx_arg(j));
474 result.
xdata (ii) = tmp;
475 result.
xridx (ii++) = j;
510 retval(j) =
data (k);
535 if (rb.
rows () > 0 && rb.
cols () > 0)
545 if (rb.
rows () > 0 && rb.
cols () > 0)
563 r.
data (i) = std::real (a.
data (i));
584 r.
data (i) = std::imag (a.
data (i));
602is_singular (
const double rcond)
604 return (std::abs (rcond) <= std::numeric_limits<double>::epsilon ());
613 return inverse (mattype, info, rcond, 0, 0);
621 return inverse (mattype, info, rcond, 0, 0);
628 return inverse (mattype, info, rcond, 0, 0);
633 double& rcond,
const bool,
634 const bool calccond)
const
642 if (nr == 0 || nc == 0 || nr != nc)
643 (*current_liboctave_error_handler) (
"inverse requires square matrix");
646 int typ = mattype.
type ();
650 (*current_liboctave_error_handler) (
"incorrect matrix type");
658 double *v = retval.
data ();
663 double dmin = octave::numeric_limits<double>::Inf ();
666 double tmp = fabs (v[i]);
683 double& rcond,
const bool,
684 const bool calccond)
const
692 if (nr == 0 || nc == 0 || nr != nc)
693 (*current_liboctave_error_handler) (
"inverse requires square matrix");
696 int typ = mattype.
type ();
701 (*current_liboctave_error_handler) (
"incorrect matrix type");
704 double ainvnorm = 0.;
713 atmp += fabs (
data (i));
738 retval.
xcidx (i) = cx;
739 retval.
xridx (cx) = i;
740 retval.
xdata (cx) = 1.0;
753 (*current_liboctave_error_handler) (
"division by zero");
758 rpX = retval.
xridx (colXp);
767 v -= retval.
xdata (colXp) *
data (colUp);
772 while (rpX < j && rpU < j && colXp < cx && colUp < nz);
776 colUp =
cidx (j+1) - 1;
779 double pivot =
data (colUp);
780 if (pivot == 0. ||
ridx (colUp) != j)
781 (*current_liboctave_error_handler) (
"division by zero");
791 retval.
xridx (cx) = j;
792 retval.
xdata (cx) = v / pivot;
800 colUp =
cidx (i+1) - 1;
803 double pivot =
data (colUp);
804 if (pivot == 0. ||
ridx (colUp) != i)
805 (*current_liboctave_error_handler) (
"division by zero");
809 retval.
xdata (j) /= pivot;
811 retval.
xcidx (nr) = cx;
856 k <
cidx (jidx+1); k++)
869 (*current_liboctave_error_handler) (
"division by zero");
877 colUp =
cidx (perm[iidx]+1) - 1;
879 colUp =
cidx (perm[iidx]);
881 double pivot =
data (colUp);
883 (*current_liboctave_error_handler) (
"division by zero");
896 nz2 = (2*nz2 < new_cx ? new_cx : 2*nz2);
900 retval.
xcidx (i) = cx;
904 retval.
xridx (cx) = j;
905 retval.
xdata (cx++) = work[j];
909 retval.
xcidx (nr) = cx;
920 i < retval.
cidx (j+1); i++)
921 atmp += fabs (retval.
data (i));
926 rcond = 1. / ainvnorm / anorm;
934 double& rcond,
bool,
bool calc_cond)
const
938 (*current_liboctave_error_handler)
939 (
"inverse of the null matrix not defined");
942 int typ = mattype.
type (
false);
946 typ = mattype.
type (*
this);
949 ret = dinverse (mattype, info, rcond,
true, calc_cond);
951 ret = tinverse (mattype, info, rcond,
true, calc_cond).
transpose ();
955 ret =
transpose ().tinverse (newtype, info, rcond,
true, calc_cond);
962 octave::math::sparse_chol<SparseMatrix> fact (*
this, info,
false);
963 rcond = fact.rcond ();
969 info, rcond2,
true,
false);
987 octave::math::sparse_lu<SparseMatrix> fact (*
this,
990 rcond = fact.rcond ();
997 octave::numeric_limits<double>::Inf ());
1006 info, rcond2,
true,
false);
1007 SparseMatrix InvU = fact.U ().tinverse (tmp_typ, info, rcond2,
1009 ret = fact.Pc ().
transpose () * InvU * InvL * fact.Pr ();
1036#if defined (HAVE_UMFPACK)
1041 if (nr == 0 || nc == 0 || nr != nc)
1050 Matrix Control (UMFPACK_CONTROL, 1);
1051 double *control = Control.
rwdata ();
1054 double tmp = octave::sparse_params::get_key (
"spumoni");
1055 if (! octave::math::isnan (tmp))
1056 Control (UMFPACK_PRL) = tmp;
1058 tmp = octave::sparse_params::get_key (
"piv_tol");
1059 if (! octave::math::isnan (tmp))
1061 Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
1062 Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
1066 tmp = octave::sparse_params::get_key (
"autoamd");
1067 if (! octave::math::isnan (tmp))
1068 Control (UMFPACK_FIXQ) = tmp;
1071 Control (UMFPACK_SCALE) = UMFPACK_SCALE_NONE;
1077 const double *Ax =
data ();
1080 octave::to_suitesparse_intptr (Ap),
1081 octave::to_suitesparse_intptr (Ai),
1085 Matrix Info (1, UMFPACK_INFO);
1086 double *info = Info.
rwdata ();
1088 octave::to_suitesparse_intptr (Ap),
1089 octave::to_suitesparse_intptr (Ai),
1090 Ax,
nullptr, &Symbolic, control, info);
1099 (*current_liboctave_error_handler)
1100 (
"SparseMatrix::determinant symbolic factorization failed");
1107 status =
UMFPACK_DNAME (numeric) (octave::to_suitesparse_intptr (Ap),
1108 octave::to_suitesparse_intptr (Ai),
1110 &Numeric, control, info);
1113 rcond = Info (UMFPACK_RCOND);
1121 (*current_liboctave_error_handler)
1122 (
"SparseMatrix::determinant numeric factorization failed");
1130 status =
UMFPACK_DNAME (get_determinant) (&c10, &e10, Numeric,
1138 (*current_liboctave_error_handler)
1139 (
"SparseMatrix::determinant error calculating determinant");
1142 retval =
DET (c10, e10, 10);
1151 octave_unused_parameter (err);
1152 octave_unused_parameter (rcond);
1154 (*current_liboctave_error_handler)
1155 (
"support for UMFPACK was unavailable or disabled "
1156 "when liboctave was built");
1166 double& rcond, solve_singularity_handler,
1167 bool calc_cond)
const
1176 if (nr != b.
rows ())
1178 (
"matrix dimension mismatch solution of linear equations");
1180 if (nr == 0 || nc == 0 || b.
cols () == 0)
1185 int typ = mattype.
type ();
1189 (*current_liboctave_error_handler) (
"incorrect matrix type");
1195 retval(i, j) = b(i, j) /
data (i);
1200 retval(k, j) = b(
ridx (i), j) /
data (i);
1205 double dmin = octave::numeric_limits<double>::Inf ();
1208 double tmp = fabs (
data (i));
1214 rcond = dmin / dmax;
1226 solve_singularity_handler,
bool calc_cond)
const
1235 if (nr != b.
rows ())
1237 (
"matrix dimension mismatch solution of linear equations");
1239 if (nr == 0 || nc == 0 || b.
cols () == 0)
1244 int typ = mattype.
type ();
1248 (*current_liboctave_error_handler) (
"incorrect matrix type");
1254 retval.
xcidx (0) = 0;
1261 if (b.
ridx (i) >= nm)
1266 retval.
xcidx (j+1) = ii;
1276 for (k = b.
cidx (j); k < b.
cidx (j+1); k++)
1284 retval.
xridx (ii) = l;
1288 retval.
xcidx (j+1) = ii;
1294 double dmin = octave::numeric_limits<double>::Inf ();
1297 double tmp = fabs (
data (i));
1303 rcond = dmin / dmax;
1315 solve_singularity_handler,
bool calc_cond)
const
1324 if (nr != b.
rows ())
1326 (
"matrix dimension mismatch solution of linear equations");
1328 if (nr == 0 || nc == 0 || b.
cols () == 0)
1333 int typ = mattype.
type ();
1337 (*current_liboctave_error_handler) (
"incorrect matrix type");
1343 retval(i, j) = b(i, j) /
data (i);
1348 retval(k, j) = b(
ridx (i), j) /
data (i);
1353 double dmin = octave::numeric_limits<double>::Inf ();
1356 double tmp = fabs (
data (i));
1362 rcond = dmin / dmax;
1374 solve_singularity_handler,
bool calc_cond)
const
1383 if (nr != b.
rows ())
1385 (
"matrix dimension mismatch solution of linear equations");
1387 if (nr == 0 || nc == 0 || b.
cols () == 0)
1392 int typ = mattype.
type ();
1396 (*current_liboctave_error_handler) (
"incorrect matrix type");
1402 retval.
xcidx (0) = 0;
1409 if (b.
ridx (i) >= nm)
1414 retval.
xcidx (j+1) = ii;
1424 for (k = b.
cidx (j); k < b.
cidx (j+1); k++)
1432 retval.
xridx (ii) = l;
1436 retval.
xcidx (j+1) = ii;
1442 double dmin = octave::numeric_limits<double>::Inf ();
1445 double tmp = fabs (
data (i));
1451 rcond = dmin / dmax;
1463 solve_singularity_handler sing_handler,
1464 bool calc_cond)
const
1473 if (nr != b.
rows ())
1475 (
"matrix dimension mismatch solution of linear equations");
1477 if (nr == 0 || nc == 0 || b.
cols () == 0)
1482 int typ = mattype.
type ();
1486 (*current_liboctave_error_handler) (
"incorrect matrix type");
1489 double ainvnorm = 0.;
1500 atmp += fabs (
data (i));
1508 retval.
resize (nc, b_nc);
1529 goto triangular_error;
1532 double tmp = work[k] /
data (
cidx (kidx+1)-1);
1535 i <
cidx (kidx+1)-1; i++)
1538 work[iidx] = work[iidx] - tmp *
data (i);
1544 retval.
xelem (perm[i], j) = work[i];
1563 double tmp = work[k] /
data (
cidx (iidx+1)-1);
1566 i <
cidx (iidx+1)-1; i++)
1569 work[idx2] = work[idx2] - tmp *
data (i);
1576 atmp += fabs (work[i]);
1579 if (atmp > ainvnorm)
1582 rcond = 1. / ainvnorm / anorm;
1588 retval.
resize (nc, b_nc);
1605 goto triangular_error;
1608 double tmp = work[k] /
data (
cidx (k+1)-1);
1613 work[iidx] = work[iidx] - tmp *
data (i);
1619 retval.
xelem (i, j) = work[i];
1636 double tmp = work[k] /
data (
cidx (k+1)-1);
1641 work[iidx] = work[iidx] - tmp *
data (i);
1648 atmp += fabs (work[i]);
1651 if (atmp > ainvnorm)
1654 rcond = 1. / ainvnorm / anorm;
1663 sing_handler (rcond);
1667 octave::warn_singular_matrix (rcond);
1670 if (is_singular (rcond) || octave::math::isnan (rcond))
1676 sing_handler (rcond);
1680 octave::warn_singular_matrix (rcond);
1690 solve_singularity_handler sing_handler,
1691 bool calc_cond)
const
1700 if (nr != b.
rows ())
1702 (
"matrix dimension mismatch solution of linear equations");
1704 if (nr == 0 || nc == 0 || b.
cols () == 0)
1709 int typ = mattype.
type ();
1713 (*current_liboctave_error_handler) (
"incorrect matrix type");
1716 double ainvnorm = 0.;
1726 atmp += fabs (
data (i));
1735 retval.
xcidx (0) = 0;
1765 goto triangular_error;
1768 double tmp = work[k] /
data (
cidx (kidx+1)-1);
1771 i <
cidx (kidx+1)-1; i++)
1774 work[iidx] = work[iidx] - tmp *
data (i);
1786 if (ii + new_nnz > x_nz)
1795 if (work[rperm[i]] != 0.)
1797 retval.
xridx (ii) = i;
1798 retval.
xdata (ii++) = work[rperm[i]];
1800 retval.
xcidx (j+1) = ii;
1821 double tmp = work[k] /
data (
cidx (iidx+1)-1);
1824 i <
cidx (iidx+1)-1; i++)
1827 work[idx2] = work[idx2] - tmp *
data (i);
1834 atmp += fabs (work[i]);
1837 if (atmp > ainvnorm)
1840 rcond = 1. / ainvnorm / anorm;
1862 goto triangular_error;
1865 double tmp = work[k] /
data (
cidx (k+1)-1);
1870 work[iidx] = work[iidx] - tmp *
data (i);
1882 if (ii + new_nnz > x_nz)
1893 retval.
xridx (ii) = i;
1894 retval.
xdata (ii++) = work[i];
1896 retval.
xcidx (j+1) = ii;
1915 double tmp = work[k] /
data (
cidx (k+1)-1);
1918 i <
cidx (k+1)-1; i++)
1921 work[iidx] = work[iidx] - tmp *
data (i);
1928 atmp += fabs (work[i]);
1931 if (atmp > ainvnorm)
1934 rcond = 1. / ainvnorm / anorm;
1943 sing_handler (rcond);
1947 octave::warn_singular_matrix (rcond);
1950 if (is_singular (rcond) || octave::math::isnan (rcond))
1956 sing_handler (rcond);
1960 octave::warn_singular_matrix (rcond);
1969 solve_singularity_handler sing_handler,
1970 bool calc_cond)
const
1979 if (nr != b.
rows ())
1981 (
"matrix dimension mismatch solution of linear equations");
1983 if (nr == 0 || nc == 0 || b.
cols () == 0)
1988 int typ = mattype.
type ();
1992 (*current_liboctave_error_handler) (
"incorrect matrix type");
1995 double ainvnorm = 0.;
2006 atmp += fabs (
data (i));
2014 retval.
resize (nc, b_nc);
2035 goto triangular_error;
2041 i <
cidx (kidx+1)-1; i++)
2044 cwork[iidx] = cwork[iidx] - tmp *
data (i);
2050 retval.
xelem (perm[i], j) = cwork[i];
2070 double tmp = work[k] /
data (
cidx (iidx+1)-1);
2073 i <
cidx (iidx+1)-1; i++)
2076 work[idx2] = work[idx2] - tmp *
data (i);
2083 atmp += fabs (work[i]);
2086 if (atmp > ainvnorm)
2089 rcond = 1. / ainvnorm / anorm;
2095 retval.
resize (nc, b_nc);
2112 goto triangular_error;
2120 cwork[iidx] = cwork[iidx] - tmp *
data (i);
2126 retval.
xelem (i, j) = cwork[i];
2144 double tmp = work[k] /
data (
cidx (k+1)-1);
2147 i <
cidx (k+1)-1; i++)
2150 work[iidx] = work[iidx] - tmp *
data (i);
2157 atmp += fabs (work[i]);
2160 if (atmp > ainvnorm)
2163 rcond = 1. / ainvnorm / anorm;
2172 sing_handler (rcond);
2176 octave::warn_singular_matrix (rcond);
2179 if (is_singular (rcond) || octave::math::isnan (rcond))
2185 sing_handler (rcond);
2189 octave::warn_singular_matrix (rcond);
2199 solve_singularity_handler sing_handler,
2200 bool calc_cond)
const
2209 if (nr != b.
rows ())
2211 (
"matrix dimension mismatch solution of linear equations");
2213 if (nr == 0 || nc == 0 || b.
cols () == 0)
2218 int typ = mattype.
type ();
2222 (*current_liboctave_error_handler) (
"incorrect matrix type");
2225 double ainvnorm = 0.;
2235 atmp += fabs (
data (i));
2244 retval.
xcidx (0) = 0;
2274 goto triangular_error;
2280 i <
cidx (kidx+1)-1; i++)
2283 cwork[iidx] = cwork[iidx] - tmp *
data (i);
2295 if (ii + new_nnz > x_nz)
2304 if (cwork[rperm[i]] != 0.)
2306 retval.
xridx (ii) = i;
2307 retval.
xdata (ii++) = cwork[rperm[i]];
2309 retval.
xcidx (j+1) = ii;
2331 double tmp = work[k] /
data (
cidx (iidx+1)-1);
2334 i <
cidx (iidx+1)-1; i++)
2337 work[idx2] = work[idx2] - tmp *
data (i);
2344 atmp += fabs (work[i]);
2347 if (atmp > ainvnorm)
2350 rcond = 1. / ainvnorm / anorm;
2372 goto triangular_error;
2380 cwork[iidx] = cwork[iidx] - tmp *
data (i);
2392 if (ii + new_nnz > x_nz)
2403 retval.
xridx (ii) = i;
2404 retval.
xdata (ii++) = cwork[i];
2406 retval.
xcidx (j+1) = ii;
2426 double tmp = work[k] /
data (
cidx (k+1)-1);
2429 i <
cidx (k+1)-1; i++)
2432 work[iidx] = work[iidx] - tmp *
data (i);
2439 atmp += fabs (work[i]);
2442 if (atmp > ainvnorm)
2445 rcond = 1. / ainvnorm / anorm;
2454 sing_handler (rcond);
2458 octave::warn_singular_matrix (rcond);
2461 if (is_singular (rcond) || octave::math::isnan (rcond))
2467 sing_handler (rcond);
2471 octave::warn_singular_matrix (rcond);
2481 solve_singularity_handler sing_handler,
2482 bool calc_cond)
const
2491 if (nr != b.
rows ())
2493 (
"matrix dimension mismatch solution of linear equations");
2495 if (nr == 0 || nc == 0 || b.
cols () == 0)
2500 int typ = mattype.
type ();
2504 (*current_liboctave_error_handler) (
"incorrect matrix type");
2507 double ainvnorm = 0.;
2518 atmp += fabs (
data (i));
2526 retval.
resize (nc, b_nc);
2536 work[perm[i]] = b(i, j);
2546 if (perm[
ridx (i)] < minr)
2548 minr = perm[
ridx (i)];
2552 if (minr != k ||
data (mini) == 0)
2555 goto triangular_error;
2558 double tmp = work[k] /
data (mini);
2566 work[iidx] = work[iidx] - tmp *
data (i);
2572 retval(i, j) = work[i];
2593 i <
cidx (k+1); i++)
2594 if (perm[
ridx (i)] < minr)
2596 minr = perm[
ridx (i)];
2600 double tmp = work[k] /
data (mini);
2603 i <
cidx (k+1); i++)
2609 work[iidx] = work[iidx] - tmp *
data (i);
2617 atmp += fabs (work[i]);
2620 if (atmp > ainvnorm)
2623 rcond = 1. / ainvnorm / anorm;
2629 retval.
resize (nc, b_nc, 0.);
2644 goto triangular_error;
2647 double tmp = work[k] /
data (
cidx (k));
2650 i <
cidx (k+1); i++)
2653 work[iidx] = work[iidx] - tmp *
data (i);
2659 retval.
xelem (i, j) = work[i];
2677 double tmp = work[k] /
data (
cidx (k));
2680 i <
cidx (k+1); i++)
2683 work[iidx] = work[iidx] - tmp *
data (i);
2690 atmp += fabs (work[i]);
2693 if (atmp > ainvnorm)
2696 rcond = 1. / ainvnorm / anorm;
2705 sing_handler (rcond);
2709 octave::warn_singular_matrix (rcond);
2712 if (is_singular (rcond) || octave::math::isnan (rcond))
2718 sing_handler (rcond);
2722 octave::warn_singular_matrix (rcond);
2732 solve_singularity_handler sing_handler,
2733 bool calc_cond)
const
2742 if (nr != b.
rows ())
2744 (
"matrix dimension mismatch solution of linear equations");
2746 if (nr == 0 || nc == 0 || b.
cols () == 0)
2751 int typ = mattype.
type ();
2755 (*current_liboctave_error_handler) (
"incorrect matrix type");
2758 double ainvnorm = 0.;
2768 atmp += fabs (
data (i));
2777 retval.
xcidx (0) = 0;
2791 work[perm[b.
ridx (i)]] = b.
data (i);
2801 if (perm[
ridx (i)] < minr)
2803 minr = perm[
ridx (i)];
2807 if (minr != k ||
data (mini) == 0)
2810 goto triangular_error;
2813 double tmp = work[k] /
data (mini);
2821 work[iidx] = work[iidx] - tmp *
data (i);
2833 if (ii + new_nnz > x_nz)
2844 retval.
xridx (ii) = i;
2845 retval.
xdata (ii++) = work[i];
2847 retval.
xcidx (j+1) = ii;
2870 i <
cidx (k+1); i++)
2871 if (perm[
ridx (i)] < minr)
2873 minr = perm[
ridx (i)];
2877 double tmp = work[k] /
data (mini);
2880 i <
cidx (k+1); i++)
2886 work[iidx] = work[iidx] - tmp *
data (i);
2894 atmp += fabs (work[i]);
2897 if (atmp > ainvnorm)
2900 rcond = 1. / ainvnorm / anorm;
2921 goto triangular_error;
2924 double tmp = work[k] /
data (
cidx (k));
2929 work[iidx] = work[iidx] - tmp *
data (i);
2941 if (ii + new_nnz > x_nz)
2952 retval.
xridx (ii) = i;
2953 retval.
xdata (ii++) = work[i];
2955 retval.
xcidx (j+1) = ii;
2975 double tmp = work[k] /
data (
cidx (k));
2978 i <
cidx (k+1); i++)
2981 work[iidx] = work[iidx] - tmp *
data (i);
2988 atmp += fabs (work[i]);
2991 if (atmp > ainvnorm)
2994 rcond = 1. / ainvnorm / anorm;
3003 sing_handler (rcond);
3007 octave::warn_singular_matrix (rcond);
3010 if (is_singular (rcond) || octave::math::isnan (rcond))
3016 sing_handler (rcond);
3020 octave::warn_singular_matrix (rcond);
3030 solve_singularity_handler sing_handler,
3031 bool calc_cond)
const
3040 if (nr != b.
rows ())
3042 (
"matrix dimension mismatch solution of linear equations");
3044 if (nr == 0 || nc == 0 || b.
cols () == 0)
3049 int typ = mattype.
type ();
3053 (*current_liboctave_error_handler) (
"incorrect matrix type");
3056 double ainvnorm = 0.;
3067 atmp += fabs (
data (i));
3075 retval.
resize (nc, b_nc);
3084 cwork[perm[i]] = b(i, j);
3094 if (perm[
ridx (i)] < minr)
3096 minr = perm[
ridx (i)];
3100 if (minr != k ||
data (mini) == 0)
3103 goto triangular_error;
3114 cwork[iidx] = cwork[iidx] - tmp *
data (i);
3120 retval(i, j) = cwork[i];
3142 i <
cidx (k+1); i++)
3143 if (perm[
ridx (i)] < minr)
3145 minr = perm[
ridx (i)];
3149 double tmp = work[k] /
data (mini);
3152 i <
cidx (k+1); i++)
3158 work[iidx] = work[iidx] - tmp *
data (i);
3166 atmp += fabs (work[i]);
3169 if (atmp > ainvnorm)
3172 rcond = 1. / ainvnorm / anorm;
3178 retval.
resize (nc, b_nc, 0.);
3194 goto triangular_error;
3202 cwork[iidx] = cwork[iidx] - tmp *
data (i);
3208 retval.
xelem (i, j) = cwork[i];
3227 double tmp = work[k] /
data (
cidx (k));
3230 i <
cidx (k+1); i++)
3233 work[iidx] = work[iidx] - tmp *
data (i);
3240 atmp += fabs (work[i]);
3243 if (atmp > ainvnorm)
3246 rcond = 1. / ainvnorm / anorm;
3255 sing_handler (rcond);
3259 octave::warn_singular_matrix (rcond);
3262 if (is_singular (rcond) || octave::math::isnan (rcond))
3268 sing_handler (rcond);
3272 octave::warn_singular_matrix (rcond);
3282 solve_singularity_handler sing_handler,
3283 bool calc_cond)
const
3292 if (nr != b.
rows ())
3294 (
"matrix dimension mismatch solution of linear equations");
3296 if (nr == 0 || nc == 0 || b.
cols () == 0)
3301 int typ = mattype.
type ();
3305 (*current_liboctave_error_handler) (
"incorrect matrix type");
3308 double ainvnorm = 0.;
3318 atmp += fabs (
data (i));
3327 retval.
xcidx (0) = 0;
3341 cwork[perm[b.
ridx (i)]] = b.
data (i);
3351 if (perm[
ridx (i)] < minr)
3353 minr = perm[
ridx (i)];
3357 if (minr != k ||
data (mini) == 0)
3360 goto triangular_error;
3371 cwork[iidx] = cwork[iidx] - tmp *
data (i);
3383 if (ii + new_nnz > x_nz)
3394 retval.
xridx (ii) = i;
3395 retval.
xdata (ii++) = cwork[i];
3397 retval.
xcidx (j+1) = ii;
3421 i <
cidx (k+1); i++)
3422 if (perm[
ridx (i)] < minr)
3424 minr = perm[
ridx (i)];
3428 double tmp = work[k] /
data (mini);
3431 i <
cidx (k+1); i++)
3437 work[iidx] = work[iidx] - tmp *
data (i);
3445 atmp += fabs (work[i]);
3448 if (atmp > ainvnorm)
3451 rcond = 1. / ainvnorm / anorm;
3472 goto triangular_error;
3480 cwork[iidx] = cwork[iidx] - tmp *
data (i);
3492 if (ii + new_nnz > x_nz)
3503 retval.
xridx (ii) = i;
3504 retval.
xdata (ii++) = cwork[i];
3506 retval.
xcidx (j+1) = ii;
3527 double tmp = work[k] /
data (
cidx (k));
3530 i <
cidx (k+1); i++)
3533 work[iidx] = work[iidx] - tmp *
data (i);
3540 atmp += fabs (work[i]);
3543 if (atmp > ainvnorm)
3546 rcond = 1. / ainvnorm / anorm;
3555 sing_handler (rcond);
3559 octave::warn_singular_matrix (rcond);
3562 if (is_singular (rcond) || octave::math::isnan (rcond))
3568 sing_handler (rcond);
3572 octave::warn_singular_matrix (rcond);
3582 solve_singularity_handler sing_handler,
3583 bool calc_cond)
const
3591 if (nr != nc || nr != b.
rows ())
3592 (*current_liboctave_error_handler)
3593 (
"matrix dimension mismatch solution of linear equations");
3595 if (nr == 0 || b.
cols () == 0)
3598 (*current_liboctave_error_handler)
3599 (
"calculation of condition number not implemented");
3603 int typ = mattype.
type ();
3621 D[nc-1] =
data (ii);
3637 else if (
ridx (i) == j + 1)
3642 F77_INT tmp_nr = octave::to_f77_int (nr);
3648 double *result = retval.
rwdata ();
3652 F77_XFCN (dptsv, DPTSV, (tmp_nr, b_nc, D, DL, result,
3680 DL[j] =
data (ii++);
3681 DU[j] =
data (ii++);
3683 D[nc-1] =
data (ii);
3700 else if (
ridx (i) == j + 1)
3702 else if (
ridx (i) == j - 1)
3707 F77_INT tmp_nr = octave::to_f77_int (nr);
3713 double *result = retval.
rwdata ();
3717 F77_XFCN (dgtsv, DGTSV, (tmp_nr, b_nc, DL, D, DU, result,
3729 sing_handler (rcond);
3733 octave::warn_singular_matrix ();
3739 (*current_liboctave_error_handler) (
"incorrect matrix type");
3748 solve_singularity_handler sing_handler,
3749 bool calc_cond)
const
3757 if (nr != nc || nr != b.
rows ())
3758 (*current_liboctave_error_handler)
3759 (
"matrix dimension mismatch solution of linear equations");
3761 if (nr == 0 || b.
cols () == 0)
3764 (*current_liboctave_error_handler)
3765 (
"calculation of condition number not implemented");
3769 int typ = mattype.
type ();
3781 F77_INT *pipvt = ipvt.rwdata ();
3790 DL[j] =
data (ii++);
3791 DU[j] =
data (ii++);
3793 D[nc-1] =
data (ii);
3810 else if (
ridx (i) == j + 1)
3812 else if (
ridx (i) == j - 1)
3817 F77_INT tmp_nr = octave::to_f77_int (nr);
3821 F77_XFCN (dgttrf, DGTTRF, (tmp_nr, DL, D, DU, DU2, pipvt, tmp_err));
3830 sing_handler (rcond);
3834 octave::warn_singular_matrix ();
3843 retval.
xcidx (0) = 0;
3858 (F77_CONST_CHAR_ARG2 (&job, 1),
3859 tmp_nr, 1, DL, D, DU, DU2, pipvt,
3861 F77_CHAR_ARG_LEN (1)));
3872 if (ii + new_nnz > x_nz)
3883 retval.
xridx (ii) = i;
3884 retval.
xdata (ii++) = work[i];
3886 retval.
xcidx (j+1) = ii;
3893 (*current_liboctave_error_handler) (
"incorrect matrix type");
3902 solve_singularity_handler sing_handler,
3903 bool calc_cond)
const
3911 if (nr != nc || nr != b.
rows ())
3912 (*current_liboctave_error_handler)
3913 (
"matrix dimension mismatch solution of linear equations");
3915 if (nr == 0 || b.
cols () == 0)
3918 (*current_liboctave_error_handler)
3919 (
"calculation of condition number not implemented");
3923 int typ = mattype.
type ();
3941 D[nc-1] =
data (ii);
3957 else if (
ridx (i) == j + 1)
3962 F77_INT tmp_nr = octave::to_f77_int (nr);
4001 DL[j] =
data (ii++);
4002 DU[j] =
data (ii++);
4004 D[nc-1] =
data (ii);
4021 else if (
ridx (i) == j + 1)
4023 else if (
ridx (i) == j - 1)
4028 F77_INT tmp_nr = octave::to_f77_int (nr);
4055 sing_handler (rcond);
4059 octave::warn_singular_matrix ();
4063 (*current_liboctave_error_handler) (
"incorrect matrix type");
4072 solve_singularity_handler sing_handler,
4073 bool calc_cond)
const
4081 if (nr != nc || nr != b.
rows ())
4082 (*current_liboctave_error_handler)
4083 (
"matrix dimension mismatch solution of linear equations");
4085 if (nr == 0 || b.
cols () == 0)
4088 (*current_liboctave_error_handler)
4089 (
"calculation of condition number not implemented");
4093 int typ = mattype.
type ();
4105 F77_INT *pipvt = ipvt.rwdata ();
4114 DL[j] =
data (ii++);
4115 DU[j] =
data (ii++);
4117 D[nc-1] =
data (ii);
4134 else if (
ridx (i) == j + 1)
4136 else if (
ridx (i) == j - 1)
4141 F77_INT tmp_nr = octave::to_f77_int (nr);
4145 F77_XFCN (dgttrf, DGTTRF, (tmp_nr, DL, D, DU, DU2, pipvt, tmp_err));
4156 sing_handler (rcond);
4160 octave::warn_singular_matrix ();
4177 retval.
xcidx (0) = 0;
4181 for (
F77_INT i = 0; i < b_nr; i++)
4189 (F77_CONST_CHAR_ARG2 (&job, 1),
4190 tmp_nr, 1, DL, D, DU, DU2, pipvt,
4192 F77_CHAR_ARG_LEN (1)));
4199 (*current_liboctave_error_handler)
4200 (
"SparseMatrix::solve solve failed");
4207 (F77_CONST_CHAR_ARG2 (&job, 1),
4208 tmp_nr, 1, DL, D, DU, DU2, pipvt,
4210 F77_CHAR_ARG_LEN (1)));
4217 (*current_liboctave_error_handler)
4218 (
"SparseMatrix::solve solve failed");
4228 if (Bx[i] != 0. || Bz[i] != 0.)
4231 if (ii + new_nnz > x_nz)
4240 if (Bx[i] != 0. || Bz[i] != 0.)
4242 retval.
xridx (ii) = i;
4246 retval.
xcidx (j+1) = ii;
4253 (*current_liboctave_error_handler) (
"incorrect matrix type");
4262 solve_singularity_handler sing_handler,
4263 bool calc_cond)
const
4271 if (nr != nc || nr != b.
rows ())
4272 (*current_liboctave_error_handler)
4273 (
"matrix dimension mismatch solution of linear equations");
4275 if (nr == 0 || b.
cols () == 0)
4280 int typ = mattype.
type ();
4288 double *tmp_data = m_band.rwdata ();
4296 tmp_data[ii++] = 0.;
4304 m_band(ri - j, j) =
data (i);
4310 anorm = m_band.abs ().sum ().row (0).max ();
4312 F77_INT tmp_nr = octave::to_f77_int (nr);
4317 F77_XFCN (dpbtrf, DPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
4318 tmp_nr, n_lower, tmp_data, ldm, tmp_err
4319 F77_CHAR_ARG_LEN (1)));
4337 double *pz = z.rwdata ();
4342 (F77_CONST_CHAR_ARG2 (&job, 1),
4343 tmp_nr, n_lower, tmp_data, ldm,
4344 anorm, rcond, pz, piz, tmp_err
4345 F77_CHAR_ARG_LEN (1)));
4352 if (is_singular (rcond) || octave::math::isnan (rcond))
4358 sing_handler (rcond);
4362 octave::warn_singular_matrix (rcond);
4371 double *result = retval.
rwdata ();
4377 (F77_CONST_CHAR_ARG2 (&job, 1),
4378 tmp_nr, n_lower, b_nc, tmp_data,
4379 ldm, result, b_nr, tmp_err
4380 F77_CHAR_ARG_LEN (1)));
4387 (*current_liboctave_error_handler)
4388 (
"SparseMatrix::solve solve failed");
4400 F77_INT ldm = n_upper + 2 * n_lower + 1;
4403 double *tmp_data = m_band.rwdata ();
4409 for (
F77_INT j = 0; j < ldm; j++)
4411 tmp_data[ii++] = 0.;
4416 m_band(
ridx (i) - j + n_lower + n_upper, j) =
data (i);
4426 atmp += fabs (
data (i));
4432 F77_INT tmp_nr = octave::to_f77_int (nr);
4435 F77_INT *pipvt = ipvt.rwdata ();
4439 F77_XFCN (dgbtrf, DGBTRF, (tmp_nr, tmp_nr, n_lower, n_upper,
4440 tmp_data, ldm, pipvt, tmp_err));
4453 sing_handler (rcond);
4457 octave::warn_singular_matrix ();
4465 double *pz = z.rwdata ();
4469 F77_INT tmp_nc = octave::to_f77_int (nc);
4472 (F77_CONST_CHAR_ARG2 (&job, 1),
4473 tmp_nc, n_lower, n_upper, tmp_data, ldm, pipvt,
4474 anorm, rcond, pz, piz, tmp_err
4475 F77_CHAR_ARG_LEN (1)));
4482 if (is_singular (rcond) || octave::math::isnan (rcond))
4488 sing_handler (rcond);
4492 octave::warn_singular_matrix (rcond);
4501 double *result = retval.
rwdata ();
4508 (F77_CONST_CHAR_ARG2 (&job, 1),
4509 tmp_nr, n_lower, n_upper, b_nc, tmp_data,
4510 ldm, pipvt, result, b_nr, tmp_err
4511 F77_CHAR_ARG_LEN (1)));
4518 (*current_liboctave_error_handler) (
"incorrect matrix type");
4527 solve_singularity_handler sing_handler,
4528 bool calc_cond)
const
4536 if (nr != nc || nr != b.
rows ())
4537 (*current_liboctave_error_handler)
4538 (
"matrix dimension mismatch solution of linear equations");
4540 if (nr == 0 || b.
cols () == 0)
4545 int typ = mattype.
type ();
4551 F77_INT ldm = octave::to_f77_int (n_lower + 1);
4554 double *tmp_data = m_band.rwdata ();
4560 for (
F77_INT j = 0; j < ldm; j++)
4562 tmp_data[ii++] = 0.;
4570 m_band(ri - j, j) =
data (i);
4576 anorm = m_band.abs ().sum ().row (0).max ();
4578 F77_INT tmp_nr = octave::to_f77_int (nr);
4583 F77_XFCN (dpbtrf, DPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
4584 tmp_nr, n_lower, tmp_data, ldm, tmp_err
4585 F77_CHAR_ARG_LEN (1)));
4601 double *pz = z.rwdata ();
4606 (F77_CONST_CHAR_ARG2 (&job, 1),
4607 tmp_nr, n_lower, tmp_data, ldm,
4608 anorm, rcond, pz, piz, tmp_err
4609 F77_CHAR_ARG_LEN (1)));
4616 if (is_singular (rcond) || octave::math::isnan (rcond))
4622 sing_handler (rcond);
4626 octave::warn_singular_matrix (rcond);
4644 retval.
xcidx (0) = 0;
4647 for (
F77_INT i = 0; i < b_nr; i++)
4648 Bx[i] = b.
elem (i, j);
4651 (F77_CONST_CHAR_ARG2 (&job, 1),
4652 tmp_nr, n_lower, 1, tmp_data,
4653 ldm, Bx, b_nr, tmp_err
4654 F77_CHAR_ARG_LEN (1)));
4661 (*current_liboctave_error_handler)
4662 (
"SparseMatrix::solve solve failed");
4667 for (
F77_INT i = 0; i < b_nr; i++)
4676 sz = (
static_cast<double> (b_nc) - j) / b_nc
4678 sz = x_nz + (sz > 100 ? sz : 100);
4682 retval.
xdata (ii) = tmp;
4683 retval.
xridx (ii++) = i;
4686 retval.
xcidx (j+1) = ii;
4699 F77_INT ldm = octave::to_f77_int (n_upper + 2 * n_lower + 1);
4702 double *tmp_data = m_band.rwdata ();
4710 tmp_data[ii++] = 0.;
4715 m_band(
ridx (i) - j + n_lower + n_upper, j) =
data (i);
4726 atmp += fabs (
data (i));
4732 F77_INT tmp_nr = octave::to_f77_int (nr);
4735 F77_INT *pipvt = ipvt.rwdata ();
4739 F77_XFCN (dgbtrf, DGBTRF, (tmp_nr, tmp_nr, n_lower, n_upper,
4740 tmp_data, ldm, pipvt, tmp_err));
4751 sing_handler (rcond);
4755 octave::warn_singular_matrix ();
4763 double *pz = z.rwdata ();
4767 F77_INT tmp_nc = octave::to_f77_int (nc);
4770 (F77_CONST_CHAR_ARG2 (&job, 1),
4771 tmp_nc, n_lower, n_upper, tmp_data, ldm, pipvt,
4772 anorm, rcond, pz, piz, tmp_err
4773 F77_CHAR_ARG_LEN (1)));
4780 if (is_singular (rcond) || octave::math::isnan (rcond))
4786 sing_handler (rcond);
4790 octave::warn_singular_matrix (rcond);
4802 retval.
xcidx (0) = 0;
4812 i < b.
cidx (j+1); i++)
4818 (F77_CONST_CHAR_ARG2 (&job, 1),
4819 tmp_nr, n_lower, n_upper, 1, tmp_data,
4820 ldm, pipvt, work, b_nr, tmp_err
4821 F77_CHAR_ARG_LEN (1)));
4832 if (ii + new_nnz > x_nz)
4843 retval.
xridx (ii) = i;
4844 retval.
xdata (ii++) = work[i];
4846 retval.
xcidx (j+1) = ii;
4854 (*current_liboctave_error_handler) (
"incorrect matrix type");
4863 solve_singularity_handler sing_handler,
4864 bool calc_cond)
const
4872 if (nr != nc || nr != b.
rows ())
4873 (*current_liboctave_error_handler)
4874 (
"matrix dimension mismatch solution of linear equations");
4876 if (nr == 0 || b.
cols () == 0)
4881 int typ = mattype.
type ();
4890 double *tmp_data = m_band.rwdata ();
4896 for (
F77_INT j = 0; j < ldm; j++)
4898 tmp_data[ii++] = 0.;
4906 m_band(ri - j, j) =
data (i);
4912 anorm = m_band.abs ().sum ().row (0).max ();
4914 F77_INT tmp_nr = octave::to_f77_int (nr);
4919 F77_XFCN (dpbtrf, DPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
4920 tmp_nr, n_lower, tmp_data, ldm, tmp_err
4921 F77_CHAR_ARG_LEN (1)));
4939 double *pz = z.rwdata ();
4944 (F77_CONST_CHAR_ARG2 (&job, 1),
4945 tmp_nr, n_lower, tmp_data, ldm,
4946 anorm, rcond, pz, piz, tmp_err
4947 F77_CHAR_ARG_LEN (1)));
4954 if (is_singular (rcond) || octave::math::isnan (rcond))
4960 sing_handler (rcond);
4964 octave::warn_singular_matrix (rcond);
4978 retval.
resize (b_nr, b_nc);
4982 for (
F77_INT i = 0; i < b_nr; i++)
4990 (F77_CONST_CHAR_ARG2 (&job, 1),
4991 tmp_nr, n_lower, 1, tmp_data,
4992 ldm, Bx, b_nr, tmp_err
4993 F77_CHAR_ARG_LEN (1)));
5000 (*current_liboctave_error_handler)
5001 (
"SparseMatrix::solve solve failed");
5007 (F77_CONST_CHAR_ARG2 (&job, 1),
5008 tmp_nr, n_lower, 1, tmp_data,
5009 ldm, Bz, b_nr, tmp_err
5010 F77_CHAR_ARG_LEN (1)));
5017 (*current_liboctave_error_handler)
5018 (
"SparseMatrix::solve solve failed");
5024 retval(i, j) =
Complex (Bx[i], Bz[i]);
5035 F77_INT ldm = n_upper + 2 * n_lower + 1;
5038 double *tmp_data = m_band.rwdata ();
5044 for (
F77_INT j = 0; j < ldm; j++)
5046 tmp_data[ii++] = 0.;
5051 m_band(
ridx (i) - j + n_lower + n_upper, j) =
data (i);
5062 atmp += fabs (
data (i));
5068 F77_INT tmp_nr = octave::to_f77_int (nr);
5071 F77_INT *pipvt = ipvt.rwdata ();
5075 F77_XFCN (dgbtrf, DGBTRF, (tmp_nr, tmp_nr, n_lower, n_upper,
5076 tmp_data, ldm, pipvt, tmp_err));
5087 sing_handler (rcond);
5091 octave::warn_singular_matrix ();
5099 double *pz = z.rwdata ();
5103 F77_INT tmp_nc = octave::to_f77_int (nc);
5106 (F77_CONST_CHAR_ARG2 (&job, 1),
5107 tmp_nc, n_lower, n_upper, tmp_data, ldm, pipvt,
5108 anorm, rcond, pz, piz, tmp_err
5109 F77_CHAR_ARG_LEN (1)));
5116 if (is_singular (rcond) || octave::math::isnan (rcond))
5122 sing_handler (rcond);
5126 octave::warn_singular_matrix (rcond);
5137 retval.
resize (nr, b_nc);
5152 (F77_CONST_CHAR_ARG2 (&job, 1),
5153 tmp_nr, n_lower, n_upper, 1, tmp_data,
5154 ldm, pipvt, Bx, b_nr, tmp_err
5155 F77_CHAR_ARG_LEN (1)));
5160 (F77_CONST_CHAR_ARG2 (&job, 1),
5161 tmp_nr, n_lower, n_upper, 1, tmp_data,
5162 ldm, pipvt, Bz, b_nr, tmp_err
5163 F77_CHAR_ARG_LEN (1)));
5168 retval(i, j) =
Complex (Bx[i], Bz[i]);
5174 (*current_liboctave_error_handler) (
"incorrect matrix type");
5183 solve_singularity_handler sing_handler,
5184 bool calc_cond)
const
5192 if (nr != nc || nr != b.
rows ())
5193 (*current_liboctave_error_handler)
5194 (
"matrix dimension mismatch solution of linear equations");
5196 if (nr == 0 || b.
cols () == 0)
5201 int typ = mattype.
type ();
5210 double *tmp_data = m_band.rwdata ();
5216 for (
F77_INT j = 0; j < ldm; j++)
5218 tmp_data[ii++] = 0.;
5226 m_band(ri - j, j) =
data (i);
5232 anorm = m_band.abs ().sum ().row (0).max ();
5234 F77_INT tmp_nr = octave::to_f77_int (nr);
5239 F77_XFCN (dpbtrf, DPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
5240 tmp_nr, n_lower, tmp_data, ldm, tmp_err
5241 F77_CHAR_ARG_LEN (1)));
5260 double *pz = z.rwdata ();
5265 (F77_CONST_CHAR_ARG2 (&job, 1),
5266 tmp_nr, n_lower, tmp_data, ldm,
5267 anorm, rcond, pz, piz, tmp_err
5268 F77_CHAR_ARG_LEN (1)));
5275 if (is_singular (rcond) || octave::math::isnan (rcond))
5281 sing_handler (rcond);
5285 octave::warn_singular_matrix (rcond);
5304 retval.
xcidx (0) = 0;
5308 for (
F77_INT i = 0; i < b_nr; i++)
5316 (F77_CONST_CHAR_ARG2 (&job, 1),
5317 tmp_nr, n_lower, 1, tmp_data,
5318 ldm, Bx, b_nr, tmp_err
5319 F77_CHAR_ARG_LEN (1)));
5326 (*current_liboctave_error_handler)
5327 (
"SparseMatrix::solve solve failed");
5333 (F77_CONST_CHAR_ARG2 (&job, 1),
5334 tmp_nr, n_lower, 1, tmp_data,
5335 ldm, Bz, b_nr, tmp_err
5336 F77_CHAR_ARG_LEN (1)));
5343 (*current_liboctave_error_handler)
5344 (
"SparseMatrix::solve solve failed");
5354 if (Bx[i] != 0. || Bz[i] != 0.)
5357 if (ii + new_nnz > x_nz)
5366 if (Bx[i] != 0. || Bz[i] != 0.)
5368 retval.
xridx (ii) = i;
5372 retval.
xcidx (j+1) = ii;
5385 F77_INT ldm = n_upper + 2 * n_lower + 1;
5388 double *tmp_data = m_band.rwdata ();
5394 for (
F77_INT j = 0; j < ldm; j++)
5396 tmp_data[ii++] = 0.;
5401 m_band(
ridx (i) - j + n_lower + n_upper, j) =
data (i);
5412 atmp += fabs (
data (i));
5418 F77_INT tmp_nr = octave::to_f77_int (nr);
5421 F77_INT *pipvt = ipvt.rwdata ();
5425 F77_XFCN (dgbtrf, DGBTRF, (tmp_nr, tmp_nr, n_lower, n_upper,
5426 tmp_data, ldm, pipvt, tmp_err));
5437 sing_handler (rcond);
5441 octave::warn_singular_matrix ();
5449 double *pz = z.rwdata ();
5453 F77_INT tmp_nc = octave::to_f77_int (nc);
5456 (F77_CONST_CHAR_ARG2 (&job, 1),
5457 tmp_nc, n_lower, n_upper, tmp_data, ldm, pipvt,
5458 anorm, rcond, pz, piz, tmp_err
5459 F77_CHAR_ARG_LEN (1)));
5466 if (is_singular (rcond) || octave::math::isnan (rcond))
5472 sing_handler (rcond);
5476 octave::warn_singular_matrix (rcond);
5489 retval.
xcidx (0) = 0;
5503 i < b.
cidx (j+1); i++)
5506 Bx[b.
ridx (i)] = c.real ();
5507 Bz[b.
ridx (i)] = c.imag ();
5511 (F77_CONST_CHAR_ARG2 (&job, 1),
5512 tmp_nr, n_lower, n_upper, 1, tmp_data,
5513 ldm, pipvt, Bx, b_nr, tmp_err
5514 F77_CHAR_ARG_LEN (1)));
5519 (F77_CONST_CHAR_ARG2 (&job, 1),
5520 tmp_nr, n_lower, n_upper, 1, tmp_data,
5521 ldm, pipvt, Bz, b_nr, tmp_err
5522 F77_CHAR_ARG_LEN (1)));
5530 if (Bx[i] != 0. || Bz[i] != 0.)
5533 if (ii + new_nnz > x_nz)
5542 if (Bx[i] != 0. || Bz[i] != 0.)
5544 retval.
xridx (ii) = i;
5547 retval.
xcidx (j+1) = ii;
5555 (*current_liboctave_error_handler) (
"incorrect matrix type");
5563 Matrix& Info, solve_singularity_handler sing_handler,
5564 bool calc_cond)
const
5567 void *Numeric =
nullptr;
5570#if defined (HAVE_UMFPACK)
5573 Control =
Matrix (UMFPACK_CONTROL, 1);
5574 double *control = Control.
rwdata ();
5577 double tmp = octave::sparse_params::get_key (
"spumoni");
5578 if (! octave::math::isnan (tmp))
5579 Control (UMFPACK_PRL) = tmp;
5580 tmp = octave::sparse_params::get_key (
"piv_tol");
5581 if (! octave::math::isnan (tmp))
5583 Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
5584 Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
5588 tmp = octave::sparse_params::get_key (
"autoamd");
5589 if (! octave::math::isnan (tmp))
5590 Control (UMFPACK_FIXQ) = tmp;
5596 const double *Ax =
data ();
5601 octave::to_suitesparse_intptr (Ap),
5602 octave::to_suitesparse_intptr (Ai),
5606 Info =
Matrix (1, UMFPACK_INFO);
5607 double *info = Info.
rwdata ();
5609 octave::to_suitesparse_intptr (Ap),
5610 octave::to_suitesparse_intptr (Ai),
5611 Ax,
nullptr, &Symbolic, control, info);
5621 (*current_liboctave_error_handler)
5622 (
"SparseMatrix::solve symbolic factorization failed");
5629 status =
UMFPACK_DNAME (numeric) (octave::to_suitesparse_intptr (Ap),
5630 octave::to_suitesparse_intptr (Ai),
5631 Ax, Symbolic, &Numeric, control, info);
5635 rcond = Info (UMFPACK_RCOND);
5639 if (status == UMFPACK_WARNING_singular_matrix
5640 || is_singular (rcond) || octave::math::isnan (rcond))
5647 sing_handler (rcond);
5649 octave::warn_singular_matrix (rcond);
5651 else if (status < 0)
5657 (*current_liboctave_error_handler)
5658 (
"SparseMatrix::solve numeric factorization failed");
5673 octave_unused_parameter (rcond);
5674 octave_unused_parameter (Control);
5675 octave_unused_parameter (Info);
5676 octave_unused_parameter (sing_handler);
5677 octave_unused_parameter (calc_cond);
5679 (*current_liboctave_error_handler)
5680 (
"support for UMFPACK was unavailable or disabled "
5681 "when liboctave was built");
5691 solve_singularity_handler sing_handler,
5692 bool calc_cond)
const
5700 if (nr != nc || nr != b.
rows ())
5701 (*current_liboctave_error_handler)
5702 (
"matrix dimension mismatch solution of linear equations");
5704 if (nr == 0 || b.
cols () == 0)
5709 int typ = mattype.
type ();
5714#if defined (HAVE_CHOLMOD)
5715 cholmod_common Common;
5716 cholmod_common *cm = &Common;
5720 cm->prefer_zomplex =
false;
5722 double spu = octave::sparse_params::get_key (
"spumoni");
5726 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
nullptr);
5730 cm->print =
static_cast<int> (spu) + 2;
5731 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &
SparseCholPrint);
5735 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex);
5736 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
5738 cm->final_ll =
true;
5740 cholmod_sparse Astore;
5741 cholmod_sparse *
A = &Astore;
5751#if defined (OCTAVE_ENABLE_64)
5752 A->itype = CHOLMOD_LONG;
5754 A->itype = CHOLMOD_INT;
5756 A->dtype = CHOLMOD_DOUBLE;
5758 A->xtype = CHOLMOD_REAL;
5762 cholmod_dense Bstore;
5763 cholmod_dense *
B = &Bstore;
5764 B->nrow = b.
rows ();
5765 B->ncol = b.
cols ();
5767 B->nzmax =
B->nrow *
B->ncol;
5768 B->dtype = CHOLMOD_DOUBLE;
5769 B->xtype = CHOLMOD_REAL;
5771 B->x =
const_cast<double *
> (b.
data ());
5788 if (is_singular (rcond) || octave::math::isnan (rcond))
5794 sing_handler (rcond);
5798 octave::warn_singular_matrix (rcond);
5810 retval.
xelem (i, j) =
static_cast<double *
> (X->x)[jr + i];
5816 static char blank_name[] =
" ";
5820 (*current_liboctave_warning_with_id_handler)
5821 (
"Octave:missing-dependency",
5822 "support for CHOLMOD was unavailable or disabled "
5823 "when liboctave was built");
5832#if defined (HAVE_UMFPACK)
5835 = factorize (err, rcond, Control, Info, sing_handler, calc_cond);
5840 Control (UMFPACK_IRSTEP) = 1;
5841 const double *Bx = b.
data ();
5843 double *result = retval.
rwdata ();
5847 double *control = Control.
rwdata ();
5848 double *info = Info.
rwdata ();
5851 const double *Ax =
data ();
5856 octave::to_suitesparse_intptr (Ap),
5857 octave::to_suitesparse_intptr (Ai),
5858 Ax, &result[iidx], &Bx[iidx],
5859 Numeric, control, info);
5865 (*current_liboctave_error_handler)
5866 (
"SparseMatrix::solve solve failed");
5881 octave_unused_parameter (rcond);
5882 octave_unused_parameter (sing_handler);
5883 octave_unused_parameter (calc_cond);
5885 (*current_liboctave_error_handler)
5886 (
"support for UMFPACK was unavailable or disabled "
5887 "when liboctave was built");
5891 (*current_liboctave_error_handler) (
"incorrect matrix type");
5900 solve_singularity_handler sing_handler,
5901 bool calc_cond)
const
5909 if (nr != nc || nr != b.
rows ())
5910 (*current_liboctave_error_handler)
5911 (
"matrix dimension mismatch solution of linear equations");
5913 if (nr == 0 || b.
cols () == 0)
5918 int typ = mattype.
type ();
5923#if defined (HAVE_CHOLMOD)
5924 cholmod_common Common;
5925 cholmod_common *cm = &Common;
5929 cm->prefer_zomplex =
false;
5931 double spu = octave::sparse_params::get_key (
"spumoni");
5935 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
nullptr);
5939 cm->print =
static_cast<int> (spu) + 2;
5940 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &
SparseCholPrint);
5944 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex);
5945 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
5947 cm->final_ll =
true;
5949 cholmod_sparse Astore;
5950 cholmod_sparse *
A = &Astore;
5960#if defined (OCTAVE_ENABLE_64)
5961 A->itype = CHOLMOD_LONG;
5963 A->itype = CHOLMOD_INT;
5965 A->dtype = CHOLMOD_DOUBLE;
5967 A->xtype = CHOLMOD_REAL;
5971 cholmod_sparse Bstore;
5972 cholmod_sparse *
B = &Bstore;
5973 B->nrow = b.
rows ();
5974 B->ncol = b.
cols ();
5977 B->nzmax = b.
nnz ();
5981#if defined (OCTAVE_ENABLE_64)
5982 B->itype = CHOLMOD_LONG;
5984 B->itype = CHOLMOD_INT;
5986 B->dtype = CHOLMOD_DOUBLE;
5988 B->xtype = CHOLMOD_REAL;
6007 if (is_singular (rcond) || octave::math::isnan (rcond))
6013 sing_handler (rcond);
6017 octave::warn_singular_matrix (rcond);
6022 cholmod_sparse *X =
CHOLMOD_NAME(spsolve) (CHOLMOD_A, L,
B, cm);
6025 (octave::from_size_t (X->nrow),
6026 octave::from_size_t (X->ncol),
6030 j <= static_cast<octave_idx_type> (X->ncol); j++)
6037 retval.
xdata (j) =
static_cast<double *
> (X->x)[j];
6043 static char blank_name[] =
" ";
6047 (*current_liboctave_warning_with_id_handler)
6048 (
"Octave:missing-dependency",
6049 "support for CHOLMOD was unavailable or disabled "
6050 "when liboctave was built");
6059#if defined (HAVE_UMFPACK)
6061 void *Numeric = factorize (err, rcond, Control, Info,
6062 sing_handler, calc_cond);
6067 Control (UMFPACK_IRSTEP) = 1;
6071 double *control = Control.
rwdata ();
6072 double *info = Info.
rwdata ();
6075 const double *Ax =
data ();
6086 retval.
xcidx (0) = 0;
6091 Bx[i] = b.
elem (i, j);
6094 octave::to_suitesparse_intptr (Ap),
6095 octave::to_suitesparse_intptr (Ai),
6096 Ax, Xx, Bx, Numeric,
6103 (*current_liboctave_error_handler)
6104 (
"SparseMatrix::solve solve failed");
6119 sz = (
static_cast<double> (b_nc) - j) / b_nc
6121 sz = x_nz + (sz > 100 ? sz : 100);
6125 retval.
xdata (ii) = tmp;
6126 retval.
xridx (ii++) = i;
6129 retval.
xcidx (j+1) = ii;
6142 octave_unused_parameter (rcond);
6143 octave_unused_parameter (sing_handler);
6144 octave_unused_parameter (calc_cond);
6146 (*current_liboctave_error_handler)
6147 (
"support for UMFPACK was unavailable or disabled "
6148 "when liboctave was built");
6152 (*current_liboctave_error_handler) (
"incorrect matrix type");
6161 solve_singularity_handler sing_handler,
6162 bool calc_cond)
const
6170 if (nr != nc || nr != b.
rows ())
6171 (*current_liboctave_error_handler)
6172 (
"matrix dimension mismatch solution of linear equations");
6174 if (nr == 0 || b.
cols () == 0)
6179 int typ = mattype.
type ();
6184#if defined (HAVE_CHOLMOD)
6185 cholmod_common Common;
6186 cholmod_common *cm = &Common;
6190 cm->prefer_zomplex =
false;
6192 double spu = octave::sparse_params::get_key (
"spumoni");
6196 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
nullptr);
6200 cm->print =
static_cast<int> (spu) + 2;
6201 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &
SparseCholPrint);
6205 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex);
6206 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
6208 cm->final_ll =
true;
6210 cholmod_sparse Astore;
6211 cholmod_sparse *
A = &Astore;
6221#if defined (OCTAVE_ENABLE_64)
6222 A->itype = CHOLMOD_LONG;
6224 A->itype = CHOLMOD_INT;
6226 A->dtype = CHOLMOD_DOUBLE;
6228 A->xtype = CHOLMOD_REAL;
6232 cholmod_dense Bstore;
6233 cholmod_dense *
B = &Bstore;
6234 B->nrow = b.
rows ();
6235 B->ncol = b.
cols ();
6237 B->nzmax =
B->nrow *
B->ncol;
6238 B->dtype = CHOLMOD_DOUBLE;
6239 B->xtype = CHOLMOD_COMPLEX;
6258 if (is_singular (rcond) || octave::math::isnan (rcond))
6264 sing_handler (rcond);
6268 octave::warn_singular_matrix (rcond);
6280 retval.
xelem (i, j) =
static_cast<Complex *
> (X->x)[jr + i];
6286 static char blank_name[] =
" ";
6290 (*current_liboctave_warning_with_id_handler)
6291 (
"Octave:missing-dependency",
6292 "support for CHOLMOD was unavailable or disabled "
6293 "when liboctave was built");
6302#if defined (HAVE_UMFPACK)
6304 void *Numeric = factorize (err, rcond, Control, Info,
6305 sing_handler, calc_cond);
6310 Control (UMFPACK_IRSTEP) = 1;
6314 double *control = Control.
rwdata ();
6315 double *info = Info.
rwdata ();
6318 const double *Ax =
data ();
6323 retval.
resize (b_nr, b_nc);
6338 octave::to_suitesparse_intptr (Ap),
6339 octave::to_suitesparse_intptr (Ai),
6340 Ax, Xx, Bx, Numeric,
6343 octave::to_suitesparse_intptr (Ap),
6344 octave::to_suitesparse_intptr (Ai),
6346 Numeric, control, info);
6348 if (status < 0 || status2 < 0)
6353 (*current_liboctave_error_handler)
6354 (
"SparseMatrix::solve solve failed");
6361 retval(i, j) =
Complex (Xx[i], Xz[i]);
6372 octave_unused_parameter (rcond);
6373 octave_unused_parameter (sing_handler);
6374 octave_unused_parameter (calc_cond);
6376 (*current_liboctave_error_handler)
6377 (
"support for UMFPACK was unavailable or disabled "
6378 "when liboctave was built");
6382 (*current_liboctave_error_handler) (
"incorrect matrix type");
6391 solve_singularity_handler sing_handler,
6392 bool calc_cond)
const
6400 if (nr != nc || nr != b.
rows ())
6401 (*current_liboctave_error_handler)
6402 (
"matrix dimension mismatch solution of linear equations");
6404 if (nr == 0 || b.
cols () == 0)
6409 int typ = mattype.
type ();
6414#if defined (HAVE_CHOLMOD)
6415 cholmod_common Common;
6416 cholmod_common *cm = &Common;
6420 cm->prefer_zomplex =
false;
6422 double spu = octave::sparse_params::get_key (
"spumoni");
6426 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
nullptr);
6430 cm->print =
static_cast<int> (spu) + 2;
6431 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &
SparseCholPrint);
6435 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex);
6436 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
6438 cm->final_ll =
true;
6440 cholmod_sparse Astore;
6441 cholmod_sparse *
A = &Astore;
6451#if defined (OCTAVE_ENABLE_64)
6452 A->itype = CHOLMOD_LONG;
6454 A->itype = CHOLMOD_INT;
6456 A->dtype = CHOLMOD_DOUBLE;
6458 A->xtype = CHOLMOD_REAL;
6462 cholmod_sparse Bstore;
6463 cholmod_sparse *
B = &Bstore;
6464 B->nrow = b.
rows ();
6465 B->ncol = b.
cols ();
6468 B->nzmax = b.
nnz ();
6472#if defined (OCTAVE_ENABLE_64)
6473 B->itype = CHOLMOD_LONG;
6475 B->itype = CHOLMOD_INT;
6477 B->dtype = CHOLMOD_DOUBLE;
6479 B->xtype = CHOLMOD_COMPLEX;
6498 if (is_singular (rcond) || octave::math::isnan (rcond))
6504 sing_handler (rcond);
6508 octave::warn_singular_matrix (rcond);
6513 cholmod_sparse *X =
CHOLMOD_NAME(spsolve) (CHOLMOD_A, L,
B, cm);
6516 (octave::from_size_t (X->nrow),
6517 octave::from_size_t (X->ncol),
6521 j <= static_cast<octave_idx_type> (X->ncol); j++)
6534 static char blank_name[] =
" ";
6538 (*current_liboctave_warning_with_id_handler)
6539 (
"Octave:missing-dependency",
6540 "support for CHOLMOD was unavailable or disabled "
6541 "when liboctave was built");
6550#if defined (HAVE_UMFPACK)
6552 void *Numeric = factorize (err, rcond, Control, Info,
6553 sing_handler, calc_cond);
6558 Control (UMFPACK_IRSTEP) = 1;
6562 double *control = Control.
rwdata ();
6563 double *info = Info.
rwdata ();
6566 const double *Ax =
data ();
6580 retval.
xcidx (0) = 0;
6591 octave::to_suitesparse_intptr (Ap),
6592 octave::to_suitesparse_intptr (Ai),
6593 Ax, Xx, Bx, Numeric,
6596 octave::to_suitesparse_intptr (Ap),
6597 octave::to_suitesparse_intptr (Ai),
6599 Numeric, control, info);
6601 if (status < 0 || status2 < 0)
6606 (*current_liboctave_error_handler)
6607 (
"SparseMatrix::solve solve failed");
6622 sz = (
static_cast<double> (b_nc) - j) / b_nc
6624 sz = x_nz + (sz > 100 ? sz : 100);
6628 retval.
xdata (ii) = tmp;
6629 retval.
xridx (ii++) = i;
6632 retval.
xcidx (j+1) = ii;
6644 octave_unused_parameter (rcond);
6645 octave_unused_parameter (sing_handler);
6646 octave_unused_parameter (calc_cond);
6648 (*current_liboctave_error_handler)
6649 (
"support for UMFPACK was unavailable or disabled "
6650 "when liboctave was built");
6654 (*current_liboctave_error_handler) (
"incorrect matrix type");
6665 return solve (mattype, b, info, rcond,
nullptr);
6673 return solve (mattype, b, info, rcond,
nullptr);
6680 return solve (mattype, b, info, rcond,
nullptr);
6685 double& rcond, solve_singularity_handler sing_handler,
6686 bool singular_fallback)
const
6689 int typ = mattype.
type (
false);
6692 typ = mattype.
type (*
this);
6696 retval = dsolve (mattype, b, err, rcond, sing_handler,
false);
6698 retval = utsolve (mattype, b, err, rcond, sing_handler,
false);
6700 retval = ltsolve (mattype, b, err, rcond, sing_handler,
false);
6702 retval = bsolve (mattype, b, err, rcond, sing_handler,
false);
6705 retval = trisolve (mattype, b, err, rcond, sing_handler,
false);
6707 retval = fsolve (mattype, b, err, rcond, sing_handler,
true);
6709 (*current_liboctave_error_handler) (
"unknown matrix type");
6726 return solve (mattype, b, info, rcond,
nullptr);
6734 return solve (mattype, b, info, rcond,
nullptr);
6741 return solve (mattype, b, info, rcond,
nullptr);
6747 solve_singularity_handler sing_handler,
6748 bool singular_fallback)
const
6751 int typ = mattype.
type (
false);
6754 typ = mattype.
type (*
this);
6757 retval = dsolve (mattype, b, err, rcond, sing_handler,
false);
6759 retval = utsolve (mattype, b, err, rcond, sing_handler,
false);
6761 retval = ltsolve (mattype, b, err, rcond, sing_handler,
false);
6763 retval = bsolve (mattype, b, err, rcond, sing_handler,
false);
6766 retval = trisolve (mattype, b, err, rcond, sing_handler,
false);
6768 retval = fsolve (mattype, b, err, rcond, sing_handler,
true);
6770 (*current_liboctave_error_handler) (
"unknown matrix type");
6787 return solve (mattype, b, info, rcond,
nullptr);
6795 return solve (mattype, b, info, rcond,
nullptr);
6802 return solve (mattype, b, info, rcond,
nullptr);
6808 solve_singularity_handler sing_handler,
6809 bool singular_fallback)
const
6812 int typ = mattype.
type (
false);
6815 typ = mattype.
type (*
this);
6818 retval = dsolve (mattype, b, err, rcond, sing_handler,
false);
6820 retval = utsolve (mattype, b, err, rcond, sing_handler,
false);
6822 retval = ltsolve (mattype, b, err, rcond, sing_handler,
false);
6824 retval = bsolve (mattype, b, err, rcond, sing_handler,
false);
6827 retval = trisolve (mattype, b, err, rcond, sing_handler,
false);
6829 retval = fsolve (mattype, b, err, rcond, sing_handler,
true);
6831 (*current_liboctave_error_handler) (
"unknown matrix type");
6848 return solve (mattype, b, info, rcond,
nullptr);
6856 return solve (mattype, b, info, rcond,
nullptr);
6863 return solve (mattype, b, info, rcond,
nullptr);
6869 solve_singularity_handler sing_handler,
6870 bool singular_fallback)
const
6873 int typ = mattype.
type (
false);
6876 typ = mattype.
type (*
this);
6879 retval = dsolve (mattype, b, err, rcond, sing_handler,
false);
6881 retval = utsolve (mattype, b, err, rcond, sing_handler,
false);
6883 retval = ltsolve (mattype, b, err, rcond, sing_handler,
false);
6885 retval = bsolve (mattype, b, err, rcond, sing_handler,
false);
6888 retval = trisolve (mattype, b, err, rcond, sing_handler,
false);
6890 retval = fsolve (mattype, b, err, rcond, sing_handler,
true);
6892 (*current_liboctave_error_handler) (
"unknown matrix type");
6908 return solve (mattype, b, info, rcond);
6916 return solve (mattype, b, info, rcond);
6923 return solve (mattype, b, info, rcond,
nullptr);
6929 solve_singularity_handler sing_handler)
const
6932 return solve (mattype, tmp, info, rcond,
6941 return solve (mattype, b, info, rcond,
nullptr);
6949 return solve (mattype, b, info, rcond,
nullptr);
6955 double& rcond)
const
6957 return solve (mattype, b, info, rcond,
nullptr);
6963 solve_singularity_handler sing_handler)
const
6966 return solve (mattype, tmp, info, rcond,
6975 return solve (b, info, rcond,
nullptr);
6982 return solve (b, info, rcond,
nullptr);
6987 double& rcond)
const
6989 return solve (b, info, rcond,
nullptr);
6994 solve_singularity_handler sing_handler)
const
6997 return solve (mattype, b, err, rcond, sing_handler);
7005 return solve (b, info, rcond,
nullptr);
7013 return solve (b, info, rcond,
nullptr);
7020 return solve (b, info, rcond,
nullptr);
7025 solve_singularity_handler sing_handler)
const
7028 return solve (mattype, b, err, rcond, sing_handler);
7035 return solve (b, info, rcond,
nullptr);
7040 double& rcond)
const
7042 return solve (b, info, rcond,
nullptr);
7048 solve_singularity_handler sing_handler)
const
7051 return solve (mattype, b, err, rcond, sing_handler);
7059 return solve (b, info, rcond,
nullptr);
7066 return solve (b, info, rcond,
nullptr);
7071 double& rcond)
const
7073 return solve (b, info, rcond,
nullptr);
7079 solve_singularity_handler sing_handler)
const
7082 return solve (mattype, b, err, rcond, sing_handler);
7089 return solve (b, info, rcond);
7096 return solve (b, info, rcond);
7101 double& rcond)
const
7103 return solve (b, info, rcond,
nullptr);
7109 solve_singularity_handler sing_handler)
const
7112 return solve (tmp, info, rcond,
7121 return solve (b, info, rcond,
nullptr);
7128 return solve (b, info, rcond,
nullptr);
7133 double& rcond)
const
7135 return solve (b, info, rcond,
nullptr);
7141 solve_singularity_handler sing_handler)
const
7144 return solve (tmp, info, rcond,
7158 if (octave::math::signbit (
data (i)))
7178 double val =
data (i);
7179 if (octave::math::isnan (val))
7193 double val =
data (i);
7194 if (octave::math::isinf (val) || octave::math::isnan (val))
7208 double val =
data (i);
7209 if (val != 0.0 && val != 1.0)
7235 double val =
data (i);
7236 if (octave::math::isnan (val) || octave::math::x_nint (val) == val)
7261 double val =
data (i);
7269 if (octave::math::x_nint (val) != val)
7279 return test_any (octave::too_large_for_float);
7286 octave::err_nan_to_logical_conversion ();
7302 if (jj <
cidx (i+1) &&
ridx (jj) == j)
7345 if ((
rows () == 1 && dim == -1) || dim == 1)
7350 (
cidx (j+1) -
cidx (j) < nr ? 0.0 : 1.0), 1.0);
7364 double d = data (i); \
7365 tmp[ridx (i)] += d * d
7368 double d = data (i); \
7386 retval.
data (i) = fabs (retval.
data (i));
7415 os << a.
ridx (i) + 1 <<
' ' << j + 1 <<
' ';
7416 octave::write_value<double> (os, a.
data (i));
7429 return read_sparse_matrix<elt_type> (is, a, octave::read_value<double>);
7493 return do_mul_dm_sm<SparseMatrix> (
d, a);
7499 return do_mul_sm_dm<SparseMatrix> (a,
d);
7505 return do_add_dm_sm<SparseMatrix> (
d, a);
7511 return do_sub_dm_sm<SparseMatrix> (
d, a);
7517 return do_add_sm_dm<SparseMatrix> (a,
d);
7523 return do_sub_sm_dm<SparseMatrix> (a,
d);
7542#define EMPTY_RETURN_CHECK(T) \
7543 if (nr == 0 || nc == 0) \
7563 double tmp = octave::math::min (
d, m.
data (i));
7567 result.
xdata (idx) = tmp;
7577 if (octave::math::min (
d, m.
data (i)) != 0.)
7583 result.
xcidx (0) = 0;
7588 double tmp = octave::math::min (
d, m.
data (i));
7592 result.
xdata (ii) = tmp;
7596 result.
xcidx (j+1) = ii;
7619 if (a_nr == b_nr && a_nc == b_nc)
7629 bool ja_lt_max = ja < ja_max;
7633 bool jb_lt_max = jb < jb_max;
7635 while (ja_lt_max || jb_lt_max)
7638 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
7640 double tmp = octave::math::min (a.
data (ja), 0.);
7648 ja_lt_max= ja < ja_max;
7650 else if ((! ja_lt_max)
7651 || (jb_lt_max && (b.
ridx (jb) < a.
ridx (ja))))
7653 double tmp = octave::math::min (0., b.
data (jb));
7661 jb_lt_max= jb < jb_max;
7665 double tmp = octave::math::min (a.
data (ja), b.
data (jb));
7673 ja_lt_max= ja < ja_max;
7675 jb_lt_max= jb < jb_max;
7685 if (a_nr == 0 || a_nc == 0)
7687 else if (b_nr == 0 || b_nc == 0)
7690 octave::err_nonconformant (
"min", a_nr, a_nc, b_nr, b_nc);
7713 double tmp = octave::math::max (
d, m.
data (i));
7718 result.
xdata (idx) = tmp;
7728 if (octave::math::max (
d, m.
data (i)) != 0.)
7734 result.
xcidx (0) = 0;
7739 double tmp = octave::math::max (
d, m.
data (i));
7742 result.
xdata (ii) = tmp;
7746 result.
xcidx (j+1) = ii;
7769 if (a_nr == b_nr && a_nc == b_nc)
7779 bool ja_lt_max = ja < ja_max;
7783 bool jb_lt_max = jb < jb_max;
7785 while (ja_lt_max || jb_lt_max)
7788 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
7790 double tmp = octave::math::max (a.
data (ja), 0.);
7798 ja_lt_max= ja < ja_max;
7800 else if ((! ja_lt_max)
7801 || (jb_lt_max && (b.
ridx (jb) < a.
ridx (ja))))
7803 double tmp = octave::math::max (0., b.
data (jb));
7811 jb_lt_max= jb < jb_max;
7815 double tmp = octave::math::max (a.
data (ja), b.
data (jb));
7823 ja_lt_max= ja < ja_max;
7825 jb_lt_max= jb < jb_max;
7835 if (a_nr == 0 || a_nc == 0)
7837 else if (b_nr == 0 || b_nc == 0)
7840 octave::err_nonconformant (
"max", a_nr, a_nc, b_nr, b_nc);