26#if defined (HAVE_CONFIG_H)
119 if (nr != nr_a || nc != nc_a || nz != nz_a)
136 return !(*
this == a);
145 if (nr == nc && nr > 0)
180Complex_NaN_result (octave::numeric_limits<double>::NaN (),
181 octave::numeric_limits<double>::NaN ());
187 return max (dummy_idx, dim);
198 if (dim >= dv.
ndims ())
211 if (nr == 0 || nc == 0 || dim >= dv.
ndims ())
218 double abs_max = octave::numeric_limits<double>::NaN ();
222 if (
ridx (i) != idx_j)
238 if (octave::math::isnan (tmp))
241 double abs_tmp = std::abs (tmp);
243 if (octave::math::isnan (abs_max) || abs_tmp > abs_max)
251 idx_arg.
elem (j) = (octave::math::isnan (tmp_max) ? 0 : idx_j);
259 result.
xcidx (0) = 0;
265 result.
xdata (ii) = tmp;
266 result.
xridx (ii++) = 0;
268 result.
xcidx (j+1) = ii;
275 if (nr == 0 || nc == 0 || dim >= dv.
ndims ())
285 if (found[
ridx (i)] == -j)
286 found[
ridx (i)] = -j - 1;
289 if (found[i] > -nc && found[i] < 0)
290 idx_arg.
elem (i) = -found[i];
300 if (octave::math::isnan (tmp))
302 else if (ix == -1 || std::abs (tmp) > std::abs (
elem (ir, ix)))
303 idx_arg.
elem (ir) = j;
309 if (idx_arg.
elem (j) == -1 ||
elem (j, idx_arg.
elem (j)) != 0.)
315 result.
xcidx (0) = 0;
316 result.
xcidx (1) = nel;
319 if (idx_arg(j) == -1)
322 result.
xdata (ii) = Complex_NaN_result;
323 result.
xridx (ii++) = j;
330 result.
xdata (ii) = tmp;
331 result.
xridx (ii++) = j;
344 return min (dummy_idx, dim);
355 if (dim >= dv.
ndims ())
368 if (nr == 0 || nc == 0 || dim >= dv.
ndims ())
375 double abs_min = octave::numeric_limits<double>::NaN ();
379 if (
ridx (i) != idx_j)
395 if (octave::math::isnan (tmp))
398 double abs_tmp = std::abs (tmp);
400 if (octave::math::isnan (abs_min) || abs_tmp < abs_min)
408 idx_arg.
elem (j) = (octave::math::isnan (tmp_min) ? 0 : idx_j);
416 result.
xcidx (0) = 0;
422 result.
xdata (ii) = tmp;
423 result.
xridx (ii++) = 0;
425 result.
xcidx (j+1) = ii;
432 if (nr == 0 || nc == 0 || dim >= dv.
ndims ())
442 if (found[
ridx (i)] == -j)
443 found[
ridx (i)] = -j - 1;
446 if (found[i] > -nc && found[i] < 0)
447 idx_arg.
elem (i) = -found[i];
457 if (octave::math::isnan (tmp))
459 else if (ix == -1 || std::abs (tmp) < std::abs (
elem (ir, ix)))
460 idx_arg.
elem (ir) = j;
466 if (idx_arg.
elem (j) == -1 ||
elem (j, idx_arg.
elem (j)) != 0.)
472 result.
xcidx (0) = 0;
473 result.
xcidx (1) = nel;
476 if (idx_arg(j) == -1)
479 result.
xdata (ii) = Complex_NaN_result;
480 result.
xridx (ii++) = j;
487 result.
xdata (ii) = tmp;
488 result.
xridx (ii++) = j;
523 retval(j) =
data (k);
550 return insert (tmp , r, c);
566 return insert (tmp , indx);
582 if (rb.
rows () > 0 && rb.
cols () > 0)
592 if (rb.
rows () > 0 && rb.
cols () > 0)
618 retval.
xcidx (i) = nz;
627 retval.
xridx (q) = j;
660is_singular (
const double rcond)
662 return (std::abs (rcond) <= std::numeric_limits<double>::epsilon ());
671 return inverse (mattype, info, rcond, 0, 0);
679 return inverse (mattype, info, rcond, 0, 0);
686 return inverse (mattype, info, rcond, 0, 0);
691 double& rcond,
const bool,
692 const bool calccond)
const
700 if (nr == 0 || nc == 0 || nr != nc)
701 (*current_liboctave_error_handler) (
"inverse requires square matrix");
704 int typ = mattype.
type ();
708 (*current_liboctave_error_handler) (
"incorrect matrix type");
721 double dmin = octave::numeric_limits<double>::Inf ();
724 double tmp = std::abs (v[i]);
741 double& rcond,
const bool,
742 const bool calccond)
const
750 if (nr == 0 || nc == 0 || nr != nc)
751 (*current_liboctave_error_handler) (
"inverse requires square matrix");
754 int typ = mattype.
type ();
759 (*current_liboctave_error_handler) (
"incorrect matrix type");
762 double ainvnorm = 0.;
771 atmp += std::abs (
data (i));
796 retval.
xcidx (i) = cx;
797 retval.
xridx (cx) = i;
798 retval.
xdata (cx) = 1.0;
811 (*current_liboctave_error_handler) (
"division by zero");
816 rpX = retval.
xridx (colXp);
825 v -= retval.
xdata (colXp) *
data (colUp);
830 while (rpX < j && rpU < j && colXp < cx && colUp < nz);
834 colUp =
cidx (j+1) - 1;
838 if (pivot == 0. ||
ridx (colUp) != j)
839 (*current_liboctave_error_handler) (
"division by zero");
849 retval.
xridx (cx) = j;
850 retval.
xdata (cx) = v / pivot;
858 colUp =
cidx (i+1) - 1;
862 if (pivot == 0. ||
ridx (colUp) != i)
863 (*current_liboctave_error_handler) (
"division by zero");
867 retval.
xdata (j) /= pivot;
869 retval.
xcidx (nr) = cx;
914 k <
cidx (jidx+1); k++)
927 (*current_liboctave_error_handler) (
"division by zero");
935 colUp =
cidx (perm[iidx]+1) - 1;
937 colUp =
cidx (perm[iidx]);
941 (*current_liboctave_error_handler) (
"division by zero");
954 nz2 = (2*nz2 < new_cx ? new_cx : 2*nz2);
958 retval.
xcidx (i) = cx;
962 retval.
xridx (cx) = j;
963 retval.
xdata (cx++) = work[j];
967 retval.
xcidx (nr) = cx;
978 i < retval.
cidx (j+1); i++)
979 atmp += std::abs (retval.
data (i));
984 rcond = 1. / ainvnorm / anorm;
992 double& rcond,
bool,
bool calc_cond)
const
996 (*current_liboctave_error_handler)
997 (
"inverse of the null matrix not defined");
1000 int typ = mattype.
type (
false);
1004 typ = mattype.
type (*
this);
1007 ret = dinverse (mattype, info, rcond,
true, calc_cond);
1009 ret = tinverse (mattype, info, rcond,
true, calc_cond).
transpose ();
1013 ret =
transpose ().tinverse (newtype, info, rcond,
true, calc_cond);
1020 octave::math::sparse_chol<SparseComplexMatrix> fact (*
this, info,
false);
1021 rcond = fact.rcond ();
1027 tinverse (tmp_typ, info, rcond2,
1046 octave::math::sparse_lu<SparseComplexMatrix> fact (*
this,
1049 rcond = fact.rcond ();
1056 octave::numeric_limits<double>::Inf ());
1057 std::copy_n (
ridx (), nz, ret.
xridx ());
1064 tinverse (tmp_typ, info, rcond2,
1067 tinverse (tmp_typ, info, rcond2,
1069 ret = fact.Pc ().
transpose () * InvU * InvL * fact.Pr ();
1097#if defined (HAVE_UMFPACK)
1102 if (nr == 0 || nc == 0 || nr != nc)
1111 Matrix Control (UMFPACK_CONTROL, 1);
1112 double *control = Control.
rwdata ();
1115 double tmp = octave::sparse_params::get_key (
"spumoni");
1116 if (! octave::math::isnan (tmp))
1117 Control (UMFPACK_PRL) = tmp;
1119 tmp = octave::sparse_params::get_key (
"piv_tol");
1120 if (! octave::math::isnan (tmp))
1122 Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
1123 Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
1127 tmp = octave::sparse_params::get_key (
"autoamd");
1128 if (! octave::math::isnan (tmp))
1129 Control (UMFPACK_FIXQ) = tmp;
1132 Control (UMFPACK_SCALE) = UMFPACK_SCALE_NONE;
1141 octave::to_suitesparse_intptr (Ap),
1142 octave::to_suitesparse_intptr (Ai),
1143 reinterpret_cast<const double *
> (Ax),
1144 nullptr, 1, control);
1147 Matrix Info (1, UMFPACK_INFO);
1148 double *info = Info.
rwdata ();
1150 octave::to_suitesparse_intptr (Ap),
1151 octave::to_suitesparse_intptr (Ai),
1152 reinterpret_cast<const double *
> (Ax),
1153 nullptr,
nullptr, &Symbolic, control, info);
1162 (*current_liboctave_error_handler)
1163 (
"SparseComplexMatrix::determinant symbolic factorization failed");
1171 =
UMFPACK_ZNAME (numeric) (octave::to_suitesparse_intptr (Ap),
1172 octave::to_suitesparse_intptr (Ai),
1173 reinterpret_cast<const double *
> (Ax),
1174 nullptr, Symbolic, &Numeric, control, info);
1177 rcond = Info (UMFPACK_RCOND);
1186 (*current_liboctave_error_handler)
1187 (
"SparseComplexMatrix::determinant numeric factorization failed");
1195 status =
UMFPACK_ZNAME (get_determinant) (c10,
nullptr, &e10,
1203 (*current_liboctave_error_handler)
1204 (
"SparseComplexMatrix::determinant error calculating determinant");
1216 octave_unused_parameter (err);
1217 octave_unused_parameter (rcond);
1219 (*current_liboctave_error_handler)
1220 (
"support for UMFPACK was unavailable or disabled when liboctave was built");
1230 solve_singularity_handler,
bool calc_cond)
const
1239 if (nr != b.
rows ())
1241 (
"matrix dimension mismatch solution of linear equations");
1243 if (nr == 0 || nc == 0 || b.
cols () == 0)
1248 int typ = mattype.
type ();
1252 (*current_liboctave_error_handler) (
"incorrect matrix type");
1258 retval(i, j) = b(i, j) /
data (i);
1263 retval(k, j) = b(
ridx (i), j) /
data (i);
1268 double dmin = octave::numeric_limits<double>::Inf ();
1271 double tmp = std::abs (
data (i));
1277 rcond = dmin / dmax;
1289 solve_singularity_handler,
1290 bool calc_cond)
const
1299 if (nr != b.
rows ())
1301 (
"matrix dimension mismatch solution of linear equations");
1303 if (nr == 0 || nc == 0 || b.
cols () == 0)
1308 int typ = mattype.
type ();
1312 (*current_liboctave_error_handler) (
"incorrect matrix type");
1318 retval.
xcidx (0) = 0;
1325 if (b.
ridx (i) >= nm)
1330 retval.
xcidx (j+1) = ii;
1340 for (k = b.
cidx (j); k < b.
cidx (j+1); k++)
1348 retval.
xridx (ii) = l;
1352 retval.
xcidx (j+1) = ii;
1358 double dmin = octave::numeric_limits<double>::Inf ();
1361 double tmp = std::abs (
data (i));
1367 rcond = dmin / dmax;
1379 solve_singularity_handler,
1380 bool calc_cond)
const
1389 if (nr != b.
rows ())
1391 (
"matrix dimension mismatch solution of linear equations");
1393 if (nr == 0 || nc == 0 || b.
cols () == 0)
1398 int typ = mattype.
type ();
1402 (*current_liboctave_error_handler) (
"incorrect matrix type");
1408 retval(i, j) = b(i, j) /
data (i);
1413 retval(k, j) = b(
ridx (i), j) /
data (i);
1418 double dmin = octave::numeric_limits<double>::Inf ();
1421 double tmp = std::abs (
data (i));
1427 rcond = dmin / dmax;
1439 solve_singularity_handler,
1440 bool calc_cond)
const
1449 if (nr != b.
rows ())
1451 (
"matrix dimension mismatch solution of linear equations");
1453 if (nr == 0 || nc == 0 || b.
cols () == 0)
1458 int typ = mattype.
type ();
1462 (*current_liboctave_error_handler) (
"incorrect matrix type");
1468 retval.
xcidx (0) = 0;
1475 if (b.
ridx (i) >= nm)
1480 retval.
xcidx (j+1) = ii;
1490 for (k = b.
cidx (j); k < b.
cidx (j+1); k++)
1498 retval.
xridx (ii) = l;
1502 retval.
xcidx (j+1) = ii;
1508 double dmin = octave::numeric_limits<double>::Inf ();
1511 double tmp = std::abs (
data (i));
1517 rcond = dmin / dmax;
1529 solve_singularity_handler sing_handler,
1530 bool calc_cond)
const
1539 if (nr != b.
rows ())
1541 (
"matrix dimension mismatch solution of linear equations");
1543 if (nr == 0 || nc == 0 || b.
cols () == 0)
1548 int typ = mattype.
type ();
1552 (*current_liboctave_error_handler) (
"incorrect matrix type");
1555 double ainvnorm = 0.;
1566 atmp += std::abs (
data (i));
1574 retval.
resize (nc, b_nc);
1595 goto triangular_error;
1601 i <
cidx (kidx+1)-1; i++)
1604 work[iidx] = work[iidx] - tmp *
data (i);
1610 retval(perm[i], j) = work[i];
1632 i <
cidx (iidx+1)-1; i++)
1635 work[idx2] = work[idx2] - tmp *
data (i);
1642 atmp += std::abs (work[i]);
1645 if (atmp > ainvnorm)
1648 rcond = 1. / ainvnorm / anorm;
1654 retval.
resize (nc, b_nc);
1671 goto triangular_error;
1679 work[iidx] = work[iidx] - tmp *
data (i);
1685 retval.
xelem (i, j) = work[i];
1705 i <
cidx (k+1)-1; i++)
1708 work[iidx] = work[iidx] - tmp *
data (i);
1715 atmp += std::abs (work[i]);
1718 if (atmp > ainvnorm)
1721 rcond = 1. / ainvnorm / anorm;
1730 sing_handler (rcond);
1734 octave::warn_singular_matrix (rcond);
1737 if (is_singular (rcond) || octave::math::isnan (rcond))
1743 sing_handler (rcond);
1747 octave::warn_singular_matrix (rcond);
1757 solve_singularity_handler sing_handler,
1758 bool calc_cond)
const
1767 if (nr != b.
rows ())
1769 (
"matrix dimension mismatch solution of linear equations");
1771 if (nr == 0 || nc == 0 || b.
cols () == 0)
1776 int typ = mattype.
type ();
1780 (*current_liboctave_error_handler) (
"incorrect matrix type");
1783 double ainvnorm = 0.;
1793 atmp += std::abs (
data (i));
1802 retval.
xcidx (0) = 0;
1832 goto triangular_error;
1838 i <
cidx (kidx+1)-1; i++)
1841 work[iidx] = work[iidx] - tmp *
data (i);
1853 if (ii + new_nnz > x_nz)
1862 if (work[rperm[i]] != 0.)
1864 retval.
xridx (ii) = i;
1865 retval.
xdata (ii++) = work[rperm[i]];
1867 retval.
xcidx (j+1) = ii;
1891 i <
cidx (iidx+1)-1; i++)
1894 work[idx2] = work[idx2] - tmp *
data (i);
1901 atmp += std::abs (work[i]);
1904 if (atmp > ainvnorm)
1907 rcond = 1. / ainvnorm / anorm;
1929 goto triangular_error;
1937 work[iidx] = work[iidx] - tmp *
data (i);
1949 if (ii + new_nnz > x_nz)
1960 retval.
xridx (ii) = i;
1961 retval.
xdata (ii++) = work[i];
1963 retval.
xcidx (j+1) = ii;
1985 i <
cidx (k+1)-1; i++)
1988 work[iidx] = work[iidx] - tmp *
data (i);
1995 atmp += std::abs (work[i]);
1998 if (atmp > ainvnorm)
2001 rcond = 1. / ainvnorm / anorm;
2010 sing_handler (rcond);
2014 octave::warn_singular_matrix (rcond);
2017 if (is_singular (rcond) || octave::math::isnan (rcond))
2023 sing_handler (rcond);
2027 octave::warn_singular_matrix (rcond);
2036 solve_singularity_handler sing_handler,
2037 bool calc_cond)
const
2046 if (nr != b.
rows ())
2048 (
"matrix dimension mismatch solution of linear equations");
2050 if (nr == 0 || nc == 0 || b.
cols () == 0)
2055 int typ = mattype.
type ();
2059 (*current_liboctave_error_handler) (
"incorrect matrix type");
2062 double ainvnorm = 0.;
2073 atmp += std::abs (
data (i));
2081 retval.
resize (nc, b_nc);
2102 goto triangular_error;
2108 i <
cidx (kidx+1)-1; i++)
2111 work[iidx] = work[iidx] - tmp *
data (i);
2117 retval(perm[i], j) = work[i];
2139 i <
cidx (iidx+1)-1; i++)
2142 work[idx2] = work[idx2] - tmp *
data (i);
2149 atmp += std::abs (work[i]);
2152 if (atmp > ainvnorm)
2155 rcond = 1. / ainvnorm / anorm;
2161 retval.
resize (nc, b_nc);
2178 goto triangular_error;
2186 work[iidx] = work[iidx] - tmp *
data (i);
2192 retval.
xelem (i, j) = work[i];
2212 i <
cidx (k+1)-1; i++)
2215 work[iidx] = work[iidx] - tmp *
data (i);
2222 atmp += std::abs (work[i]);
2225 if (atmp > ainvnorm)
2228 rcond = 1. / ainvnorm / anorm;
2237 sing_handler (rcond);
2241 octave::warn_singular_matrix (rcond);
2244 if (is_singular (rcond) || octave::math::isnan (rcond))
2250 sing_handler (rcond);
2254 octave::warn_singular_matrix (rcond);
2264 solve_singularity_handler sing_handler,
2265 bool calc_cond)
const
2274 if (nr != b.
rows ())
2276 (
"matrix dimension mismatch solution of linear equations");
2278 if (nr == 0 || nc == 0 || b.
cols () == 0)
2283 int typ = mattype.
type ();
2287 (*current_liboctave_error_handler) (
"incorrect matrix type");
2290 double ainvnorm = 0.;
2300 atmp += std::abs (
data (i));
2309 retval.
xcidx (0) = 0;
2339 goto triangular_error;
2345 i <
cidx (kidx+1)-1; i++)
2348 work[iidx] = work[iidx] - tmp *
data (i);
2360 if (ii + new_nnz > x_nz)
2369 if (work[rperm[i]] != 0.)
2371 retval.
xridx (ii) = i;
2372 retval.
xdata (ii++) = work[rperm[i]];
2374 retval.
xcidx (j+1) = ii;
2398 i <
cidx (iidx+1)-1; i++)
2401 work[idx2] = work[idx2] - tmp *
data (i);
2408 atmp += std::abs (work[i]);
2411 if (atmp > ainvnorm)
2414 rcond = 1. / ainvnorm / anorm;
2436 goto triangular_error;
2444 work[iidx] = work[iidx] - tmp *
data (i);
2456 if (ii + new_nnz > x_nz)
2467 retval.
xridx (ii) = i;
2468 retval.
xdata (ii++) = work[i];
2470 retval.
xcidx (j+1) = ii;
2492 i <
cidx (k+1)-1; i++)
2495 work[iidx] = work[iidx] - tmp *
data (i);
2502 atmp += std::abs (work[i]);
2505 if (atmp > ainvnorm)
2508 rcond = 1. / ainvnorm / anorm;
2517 sing_handler (rcond);
2521 octave::warn_singular_matrix (rcond);
2524 if (is_singular (rcond) || octave::math::isnan (rcond))
2530 sing_handler (rcond);
2534 octave::warn_singular_matrix (rcond);
2544 solve_singularity_handler sing_handler,
2545 bool calc_cond)
const
2554 if (nr != b.
rows ())
2556 (
"matrix dimension mismatch solution of linear equations");
2558 if (nr == 0 || nc == 0 || b.
cols () == 0)
2563 int typ = mattype.
type ();
2567 (*current_liboctave_error_handler) (
"incorrect matrix type");
2570 double ainvnorm = 0.;
2581 atmp += std::abs (
data (i));
2589 retval.
resize (nc, b_nc);
2598 work[perm[i]] = b(i, j);
2608 if (perm[
ridx (i)] < minr)
2610 minr = perm[
ridx (i)];
2614 if (minr != k ||
data (mini) == 0.)
2617 goto triangular_error;
2628 work[iidx] = work[iidx] - tmp *
data (i);
2634 retval(i, j) = work[i];
2655 i <
cidx (k+1); i++)
2656 if (perm[
ridx (i)] < minr)
2658 minr = perm[
ridx (i)];
2665 i <
cidx (k+1); i++)
2671 work[iidx] = work[iidx] - tmp *
data (i);
2679 atmp += std::abs (work[i]);
2682 if (atmp > ainvnorm)
2685 rcond = 1. / ainvnorm / anorm;
2691 retval.
resize (nc, b_nc, 0.);
2706 goto triangular_error;
2714 work[iidx] = work[iidx] - tmp *
data (i);
2719 retval.
xelem (i, j) = work[i];
2740 i <
cidx (k+1); i++)
2743 work[iidx] = work[iidx] - tmp *
data (i);
2750 atmp += std::abs (work[i]);
2753 if (atmp > ainvnorm)
2756 rcond = 1. / ainvnorm / anorm;
2764 sing_handler (rcond);
2768 octave::warn_singular_matrix (rcond);
2771 if (is_singular (rcond) || octave::math::isnan (rcond))
2777 sing_handler (rcond);
2781 octave::warn_singular_matrix (rcond);
2791 solve_singularity_handler sing_handler,
2792 bool calc_cond)
const
2802 if (nr != b.
rows ())
2804 (
"matrix dimension mismatch solution of linear equations");
2806 if (nr == 0 || nc == 0 || b.
cols () == 0)
2811 int typ = mattype.
type ();
2815 (*current_liboctave_error_handler) (
"incorrect matrix type");
2818 double ainvnorm = 0.;
2828 atmp += std::abs (
data (i));
2837 retval.
xcidx (0) = 0;
2851 work[perm[b.
ridx (i)]] = b.
data (i);
2861 if (perm[
ridx (i)] < minr)
2863 minr = perm[
ridx (i)];
2867 if (minr != k ||
data (mini) == 0.)
2870 goto triangular_error;
2881 work[iidx] = work[iidx] - tmp *
data (i);
2893 if (ii + new_nnz > x_nz)
2904 retval.
xridx (ii) = i;
2905 retval.
xdata (ii++) = work[i];
2907 retval.
xcidx (j+1) = ii;
2930 i <
cidx (k+1); i++)
2931 if (perm[
ridx (i)] < minr)
2933 minr = perm[
ridx (i)];
2940 i <
cidx (k+1); i++)
2946 work[iidx] = work[iidx] - tmp *
data (i);
2954 atmp += std::abs (work[i]);
2957 if (atmp > ainvnorm)
2960 rcond = 1. / ainvnorm / anorm;
2981 goto triangular_error;
2989 work[iidx] = work[iidx] - tmp *
data (i);
3001 if (ii + new_nnz > x_nz)
3012 retval.
xridx (ii) = i;
3013 retval.
xdata (ii++) = work[i];
3015 retval.
xcidx (j+1) = ii;
3038 i <
cidx (k+1); i++)
3041 work[iidx] = work[iidx] - tmp *
data (i);
3048 atmp += std::abs (work[i]);
3051 if (atmp > ainvnorm)
3054 rcond = 1. / ainvnorm / anorm;
3063 sing_handler (rcond);
3067 octave::warn_singular_matrix (rcond);
3070 if (is_singular (rcond) || octave::math::isnan (rcond))
3076 sing_handler (rcond);
3080 octave::warn_singular_matrix (rcond);
3090 solve_singularity_handler sing_handler,
3091 bool calc_cond)
const
3100 if (nr != b.
rows ())
3102 (
"matrix dimension mismatch solution of linear equations");
3104 if (nr == 0 || nc == 0 || b.
cols () == 0)
3109 int typ = mattype.
type ();
3113 (*current_liboctave_error_handler) (
"incorrect matrix type");
3116 double ainvnorm = 0.;
3127 atmp += std::abs (
data (i));
3135 retval.
resize (nc, b_nc);
3144 work[perm[i]] = b(i, j);
3154 if (perm[
ridx (i)] < minr)
3156 minr = perm[
ridx (i)];
3160 if (minr != k ||
data (mini) == 0.)
3163 goto triangular_error;
3174 work[iidx] = work[iidx] - tmp *
data (i);
3180 retval(i, j) = work[i];
3201 i <
cidx (k+1); i++)
3202 if (perm[
ridx (i)] < minr)
3204 minr = perm[
ridx (i)];
3211 i <
cidx (k+1); i++)
3217 work[iidx] = work[iidx] - tmp *
data (i);
3225 atmp += std::abs (work[i]);
3228 if (atmp > ainvnorm)
3231 rcond = 1. / ainvnorm / anorm;
3237 retval.
resize (nc, b_nc, 0.);
3253 goto triangular_error;
3261 work[iidx] = work[iidx] - tmp *
data (i);
3267 retval.
xelem (i, j) = work[i];
3288 i <
cidx (k+1); i++)
3291 work[iidx] = work[iidx] - tmp *
data (i);
3298 atmp += std::abs (work[i]);
3301 if (atmp > ainvnorm)
3304 rcond = 1. / ainvnorm / anorm;
3313 sing_handler (rcond);
3317 octave::warn_singular_matrix (rcond);
3320 if (is_singular (rcond) || octave::math::isnan (rcond))
3326 sing_handler (rcond);
3330 octave::warn_singular_matrix (rcond);
3340 solve_singularity_handler sing_handler,
3341 bool calc_cond)
const
3350 if (nr != b.
rows ())
3352 (
"matrix dimension mismatch solution of linear equations");
3354 if (nr == 0 || nc == 0 || b.
cols () == 0)
3359 int typ = mattype.
type ();
3363 (*current_liboctave_error_handler) (
"incorrect matrix type");
3366 double ainvnorm = 0.;
3376 atmp += std::abs (
data (i));
3385 retval.
xcidx (0) = 0;
3399 work[perm[b.
ridx (i)]] = b.
data (i);
3409 if (perm[
ridx (i)] < minr)
3411 minr = perm[
ridx (i)];
3415 if (minr != k ||
data (mini) == 0.)
3418 goto triangular_error;
3429 work[iidx] = work[iidx] - tmp *
data (i);
3441 if (ii + new_nnz > x_nz)
3452 retval.
xridx (ii) = i;
3453 retval.
xdata (ii++) = work[i];
3455 retval.
xcidx (j+1) = ii;
3478 i <
cidx (k+1); i++)
3479 if (perm[
ridx (i)] < minr)
3481 minr = perm[
ridx (i)];
3488 i <
cidx (k+1); i++)
3494 work[iidx] = work[iidx] - tmp *
data (i);
3502 atmp += std::abs (work[i]);
3505 if (atmp > ainvnorm)
3508 rcond = 1. / ainvnorm / anorm;
3529 goto triangular_error;
3537 work[iidx] = work[iidx] - tmp *
data (i);
3549 if (ii + new_nnz > x_nz)
3560 retval.
xridx (ii) = i;
3561 retval.
xdata (ii++) = work[i];
3563 retval.
xcidx (j+1) = ii;
3586 i <
cidx (k+1); i++)
3589 work[iidx] = work[iidx] - tmp *
data (i);
3596 atmp += std::abs (work[i]);
3599 if (atmp > ainvnorm)
3602 rcond = 1. / ainvnorm / anorm;
3611 sing_handler (rcond);
3615 octave::warn_singular_matrix (rcond);
3618 if (is_singular (rcond) || octave::math::isnan (rcond))
3624 sing_handler (rcond);
3628 octave::warn_singular_matrix (rcond);
3638 solve_singularity_handler sing_handler,
3639 bool calc_cond)
const
3647 if (nr != nc || nr != b.
rows ())
3648 (*current_liboctave_error_handler)
3649 (
"matrix dimension mismatch solution of linear equations");
3651 if (nr == 0 || b.
cols () == 0)
3654 (*current_liboctave_error_handler)
3655 (
"calculation of condition number not implemented");
3659 int typ = mattype.
type ();
3673 D[j] = std::real (
data (ii++));
3677 D[nc-1] = std::real (
data (ii));
3692 D[j] = std::real (
data (i));
3693 else if (
ridx (i) == j + 1)
3704 F77_INT tmp_nr = octave::to_f77_int (nr);
3737 DL[j] =
data (ii++);
3738 DU[j] =
data (ii++);
3740 D[nc-1] =
data (ii);
3757 else if (
ridx (i) == j + 1)
3759 else if (
ridx (i) == j - 1)
3770 F77_INT tmp_nr = octave::to_f77_int (nr);
3787 sing_handler (rcond);
3791 octave::warn_singular_matrix ();
3798 (*current_liboctave_error_handler) (
"incorrect matrix type");
3807 solve_singularity_handler sing_handler,
3808 bool calc_cond)
const
3816 if (nr != nc || nr != b.
rows ())
3817 (*current_liboctave_error_handler)
3818 (
"matrix dimension mismatch solution of linear equations");
3820 if (nr == 0 || b.
cols () == 0)
3823 (*current_liboctave_error_handler)
3824 (
"calculation of condition number not implemented");
3828 int typ = mattype.
type ();
3840 F77_INT *pipvt = ipvt.rwdata ();
3849 DL[j] =
data (ii++);
3850 DU[j] =
data (ii++);
3852 D[nc-1] =
data (ii);
3869 else if (
ridx (i) == j + 1)
3871 else if (
ridx (i) == j - 1)
3876 F77_INT tmp_nr = octave::to_f77_int (nr);
3895 sing_handler (rcond);
3899 octave::warn_singular_matrix ();
3908 retval.
xcidx (0) = 0;
3922 (F77_CONST_CHAR_ARG2 (&job, 1),
3928 F77_CHAR_ARG_LEN (1)));
3939 if (ii + new_nnz > x_nz)
3950 retval.
xridx (ii) = i;
3951 retval.
xdata (ii++) = work[i];
3953 retval.
xcidx (j+1) = ii;
3960 (*current_liboctave_error_handler) (
"incorrect matrix type");
3969 solve_singularity_handler sing_handler,
3970 bool calc_cond)
const
3978 if (nr != nc || nr != b.
rows ())
3979 (*current_liboctave_error_handler)
3980 (
"matrix dimension mismatch solution of linear equations");
3982 if (nr == 0 || b.
cols () == 0)
3985 (*current_liboctave_error_handler)
3986 (
"calculation of condition number not implemented");
3990 int typ = mattype.
type ();
4004 D[j] = std::real (
data (ii++));
4008 D[nc-1] = std::real (
data (ii));
4023 D[j] = std::real (
data (i));
4024 else if (
ridx (i) == j + 1)
4037 F77_INT tmp_nr = octave::to_f77_int (nr);
4068 DL[j] =
data (ii++);
4069 DU[j] =
data (ii++);
4071 D[nc-1] =
data (ii);
4088 else if (
ridx (i) == j + 1)
4090 else if (
ridx (i) == j - 1)
4103 F77_INT tmp_nr = octave::to_f77_int (nr);
4120 sing_handler (rcond);
4124 octave::warn_singular_matrix ();
4128 (*current_liboctave_error_handler) (
"incorrect matrix type");
4135SparseComplexMatrix::trisolve (
MatrixType& mattype,
4138 solve_singularity_handler sing_handler,
4139 bool calc_cond)
const
4147 if (nr != nc || nr != b.
rows ())
4148 (*current_liboctave_error_handler)
4149 (
"matrix dimension mismatch solution of linear equations");
4151 if (nr == 0 || b.
cols () == 0)
4154 (*current_liboctave_error_handler)
4155 (
"calculation of condition number not implemented");
4159 int typ = mattype.
type ();
4171 F77_INT *pipvt = ipvt.rwdata ();
4180 DL[j] =
data (ii++);
4181 DU[j] =
data (ii++);
4183 D[nc-1] =
data (ii);
4200 else if (
ridx (i) == j + 1)
4202 else if (
ridx (i) == j - 1)
4207 F77_INT tmp_nr = octave::to_f77_int (nr);
4226 sing_handler (rcond);
4230 octave::warn_singular_matrix ();
4246 retval.
xcidx (0) = 0;
4250 for (
F77_INT i = 0; i < b_nr; i++)
4254 (F77_CONST_CHAR_ARG2 (&job, 1),
4260 F77_CHAR_ARG_LEN (1)));
4268 (*current_liboctave_error_handler)
4269 (
"SparseComplexMatrix::solve solve failed");
4282 if (ii + new_nnz > x_nz)
4293 retval.
xridx (ii) = i;
4294 retval.
xdata (ii++) = Bx[i];
4297 retval.
xcidx (j+1) = ii;
4304 (*current_liboctave_error_handler) (
"incorrect matrix type");
4313 solve_singularity_handler sing_handler,
4314 bool calc_cond)
const
4322 if (nr != nc || nr != b.
rows ())
4323 (*current_liboctave_error_handler)
4324 (
"matrix dimension mismatch solution of linear equations");
4326 if (nr == 0 || b.
cols () == 0)
4331 int typ = mattype.
type ();
4339 Complex *tmp_data = m_band.rwdata ();
4345 for (
F77_INT j = 0; j < ldm; j++)
4347 tmp_data[ii++] = 0.;
4355 m_band(ri - j, j) =
data (i);
4361 anorm = m_band.abs ().sum ().row (0).max ();
4363 F77_INT tmp_nr = octave::to_f77_int (nr);
4368 F77_XFCN (zpbtrf, ZPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
4370 F77_CHAR_ARG_LEN (1)));
4390 double *piz = iz.rwdata ();
4393 (F77_CONST_CHAR_ARG2 (&job, 1),
4396 F77_CHAR_ARG_LEN (1)));
4403 if (is_singular (rcond) || octave::math::isnan (rcond))
4409 sing_handler (rcond);
4413 octave::warn_singular_matrix (rcond);
4428 (F77_CONST_CHAR_ARG2 (&job, 1),
4431 F77_CHAR_ARG_LEN (1)));
4438 (*current_liboctave_error_handler)
4439 (
"SparseMatrix::solve solve failed");
4451 F77_INT ldm = n_upper + 2 * n_lower + 1;
4454 Complex *tmp_data = m_band.rwdata ();
4460 for (
F77_INT j = 0; j < ldm; j++)
4462 tmp_data[ii++] = 0.;
4467 m_band(
ridx (i) - j + n_lower + n_upper, j) =
data (i);
4477 atmp += std::abs (
data (i));
4484 F77_INT *pipvt = ipvt.rwdata ();
4486 F77_INT tmp_nr = octave::to_f77_int (nr);
4490 F77_XFCN (zgbtrf, ZGBTRF, (tmp_nr, tmp_nr, n_lower, n_upper,
4492 ldm, pipvt, tmp_err));
4505 sing_handler (rcond);
4509 octave::warn_singular_matrix ();
4519 double *piz = iz.rwdata ();
4521 F77_INT tmp_nc = octave::to_f77_int (nc);
4524 (F77_CONST_CHAR_ARG2 (&job, 1),
4527 F77_CHAR_ARG_LEN (1)));
4534 if (is_singular (rcond) || octave::math::isnan (rcond))
4540 sing_handler (rcond);
4544 octave::warn_singular_matrix (rcond);
4560 (F77_CONST_CHAR_ARG2 (&job, 1),
4563 F77_CHAR_ARG_LEN (1)));
4570 (*current_liboctave_error_handler) (
"incorrect matrix type");
4579 solve_singularity_handler sing_handler,
4580 bool calc_cond)
const
4588 if (nr != nc || nr != b.
rows ())
4589 (*current_liboctave_error_handler)
4590 (
"matrix dimension mismatch solution of linear equations");
4592 if (nr == 0 || b.
cols () == 0)
4597 int typ = mattype.
type ();
4606 Complex *tmp_data = m_band.rwdata ();
4612 for (
F77_INT j = 0; j < ldm; j++)
4614 tmp_data[ii++] = 0.;
4622 m_band(ri - j, j) =
data (i);
4628 anorm = m_band.abs ().sum ().row (0).max ();
4630 F77_INT tmp_nr = octave::to_f77_int (nr);
4635 F77_XFCN (zpbtrf, ZPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
4637 F77_CHAR_ARG_LEN (1)));
4655 double *piz = iz.rwdata ();
4658 (F77_CONST_CHAR_ARG2 (&job, 1),
4661 F77_CHAR_ARG_LEN (1)));
4668 if (is_singular (rcond) || octave::math::isnan (rcond))
4674 sing_handler (rcond);
4678 octave::warn_singular_matrix (rcond);
4696 retval.
xcidx (0) = 0;
4699 for (
F77_INT i = 0; i < b_nr; i++)
4700 Bx[i] = b.
elem (i, j);
4703 (F77_CONST_CHAR_ARG2 (&job, 1),
4706 F77_CHAR_ARG_LEN (1)));
4713 (*current_liboctave_error_handler)
4714 (
"SparseComplexMatrix::solve solve failed");
4728 sz = (
static_cast<double> (b_nc) - j) / b_nc
4730 sz = x_nz + (sz > 100 ? sz : 100);
4734 retval.
xdata (ii) = tmp;
4735 retval.
xridx (ii++) = i;
4738 retval.
xcidx (j+1) = ii;
4751 F77_INT ldm = n_upper + 2 * n_lower + 1;
4754 Complex *tmp_data = m_band.rwdata ();
4760 for (
F77_INT j = 0; j < ldm; j++)
4762 tmp_data[ii++] = 0.;
4767 m_band(
ridx (i) - j + n_lower + n_upper, j) =
data (i);
4777 atmp += std::abs (
data (i));
4784 F77_INT *pipvt = ipvt.rwdata ();
4786 F77_INT tmp_nr = octave::to_f77_int (nr);
4790 F77_XFCN (zgbtrf, ZGBTRF, (tmp_nr, tmp_nr, n_lower, n_upper,
4792 ldm, pipvt, tmp_err));
4803 sing_handler (rcond);
4807 octave::warn_singular_matrix ();
4817 double *piz = iz.rwdata ();
4819 F77_INT tmp_nc = octave::to_f77_int (nc);
4822 (F77_CONST_CHAR_ARG2 (&job, 1),
4825 F77_CHAR_ARG_LEN (1)));
4832 if (is_singular (rcond) || octave::math::isnan (rcond))
4838 sing_handler (rcond);
4842 octave::warn_singular_matrix (rcond);
4855 retval.
xcidx (0) = 0;
4865 i < b.
cidx (j+1); i++)
4869 (F77_CONST_CHAR_ARG2 (&job, 1),
4872 F77_CHAR_ARG_LEN (1)));
4883 if (ii + new_nnz > x_nz)
4894 retval.
xridx (ii) = i;
4895 retval.
xdata (ii++) = work[i];
4897 retval.
xcidx (j+1) = ii;
4905 (*current_liboctave_error_handler) (
"incorrect matrix type");
4914 solve_singularity_handler sing_handler,
4915 bool calc_cond)
const
4923 if (nr != nc || nr != b.
rows ())
4924 (*current_liboctave_error_handler)
4925 (
"matrix dimension mismatch solution of linear equations");
4927 if (nr == 0 || b.
cols () == 0)
4932 int typ = mattype.
type ();
4941 Complex *tmp_data = m_band.rwdata ();
4947 for (
F77_INT j = 0; j < ldm; j++)
4949 tmp_data[ii++] = 0.;
4957 m_band(ri - j, j) =
data (i);
4963 anorm = m_band.abs ().sum ().row (0).max ();
4965 F77_INT tmp_nr = octave::to_f77_int (nr);
4970 F77_XFCN (zpbtrf, ZPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
4972 F77_CHAR_ARG_LEN (1)));
4992 double *piz = iz.rwdata ();
4995 (F77_CONST_CHAR_ARG2 (&job, 1),
4998 F77_CHAR_ARG_LEN (1)));
5005 if (is_singular (rcond) || octave::math::isnan (rcond))
5011 sing_handler (rcond);
5015 octave::warn_singular_matrix (rcond);
5029 (F77_CONST_CHAR_ARG2 (&job, 1),
5032 F77_CHAR_ARG_LEN (1)));
5039 (*current_liboctave_error_handler)
5040 (
"SparseComplexMatrix::solve solve failed");
5052 F77_INT ldm = n_upper + 2 * n_lower + 1;
5055 Complex *tmp_data = m_band.rwdata ();
5061 for (
F77_INT j = 0; j < ldm; j++)
5063 tmp_data[ii++] = 0.;
5068 m_band(
ridx (i) - j + n_lower + n_upper, j) =
data (i);
5078 atmp += std::abs (
data (i));
5085 F77_INT *pipvt = ipvt.rwdata ();
5087 F77_INT tmp_nr = octave::to_f77_int (nr);
5091 F77_XFCN (zgbtrf, ZGBTRF, (tmp_nr, tmp_nr, n_lower, n_upper,
5093 ldm, pipvt, tmp_err));
5104 sing_handler (rcond);
5108 octave::warn_singular_matrix ();
5118 double *piz = iz.rwdata ();
5120 F77_INT tmp_nc = octave::to_f77_int (nc);
5123 (F77_CONST_CHAR_ARG2 (&job, 1),
5126 F77_CHAR_ARG_LEN (1)));
5133 if (is_singular (rcond) || octave::math::isnan (rcond))
5139 sing_handler (rcond);
5143 octave::warn_singular_matrix (rcond);
5158 (F77_CONST_CHAR_ARG2 (&job, 1),
5161 F77_CHAR_ARG_LEN (1)));
5168 (*current_liboctave_error_handler) (
"incorrect matrix type");
5177 solve_singularity_handler sing_handler,
5178 bool calc_cond)
const
5186 if (nr != nc || nr != b.
rows ())
5187 (*current_liboctave_error_handler)
5188 (
"matrix dimension mismatch solution of linear equations");
5190 if (nr == 0 || b.
cols () == 0)
5195 int typ = mattype.
type ();
5204 Complex *tmp_data = m_band.rwdata ();
5210 for (
F77_INT j = 0; j < ldm; j++)
5212 tmp_data[ii++] = 0.;
5220 m_band(ri - j, j) =
data (i);
5226 anorm = m_band.abs ().sum ().row (0).max ();
5228 F77_INT tmp_nr = octave::to_f77_int (nr);
5233 F77_XFCN (zpbtrf, ZPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
5235 F77_CHAR_ARG_LEN (1)));
5256 double *piz = iz.rwdata ();
5259 (F77_CONST_CHAR_ARG2 (&job, 1),
5262 F77_CHAR_ARG_LEN (1)));
5269 if (is_singular (rcond) || octave::math::isnan (rcond))
5275 sing_handler (rcond);
5279 octave::warn_singular_matrix (rcond);
5297 retval.
xcidx (0) = 0;
5301 for (
F77_INT i = 0; i < b_nr; i++)
5305 (F77_CONST_CHAR_ARG2 (&job, 1),
5308 F77_CHAR_ARG_LEN (1)));
5315 (*current_liboctave_error_handler)
5316 (
"SparseMatrix::solve solve failed");
5328 if (ii + new_nnz > x_nz)
5339 retval.
xridx (ii) = i;
5340 retval.
xdata (ii++) = Bx[i];
5343 retval.
xcidx (j+1) = ii;
5356 F77_INT ldm = n_upper + 2 * n_lower + 1;
5359 Complex *tmp_data = m_band.rwdata ();
5365 for (
F77_INT j = 0; j < ldm; j++)
5367 tmp_data[ii++] = 0.;
5372 m_band(
ridx (i) - j + n_lower + n_upper, j) =
data (i);
5382 atmp += std::abs (
data (i));
5389 F77_INT *pipvt = ipvt.rwdata ();
5391 F77_INT tmp_nr = octave::to_f77_int (nr);
5395 F77_XFCN (zgbtrf, ZGBTRF, (tmp_nr, tmp_nr, n_lower, n_upper,
5397 ldm, pipvt, tmp_err));
5408 sing_handler (rcond);
5412 octave::warn_singular_matrix ();
5422 double *piz = iz.rwdata ();
5424 F77_INT tmp_nc = octave::to_f77_int (nc);
5427 (F77_CONST_CHAR_ARG2 (&job, 1),
5430 F77_CHAR_ARG_LEN (1)));
5437 if (is_singular (rcond) || octave::math::isnan (rcond))
5443 sing_handler (rcond);
5447 octave::warn_singular_matrix (rcond);
5460 retval.
xcidx (0) = 0;
5471 i < b.
cidx (j+1); i++)
5475 (F77_CONST_CHAR_ARG2 (&job, 1),
5478 F77_CHAR_ARG_LEN (1)));
5489 if (ii + new_nnz > x_nz)
5500 retval.
xridx (ii) = i;
5501 retval.
xdata (ii++) = Bx[i];
5503 retval.
xcidx (j+1) = ii;
5511 (*current_liboctave_error_handler) (
"incorrect matrix type");
5520 solve_singularity_handler sing_handler,
5521 bool calc_cond)
const
5524 void *Numeric =
nullptr;
5527#if defined (HAVE_UMFPACK)
5530 Control =
Matrix (UMFPACK_CONTROL, 1);
5531 double *control = Control.
rwdata ();
5534 double tmp = octave::sparse_params::get_key (
"spumoni");
5535 if (! octave::math::isnan (tmp))
5536 Control (UMFPACK_PRL) = tmp;
5537 tmp = octave::sparse_params::get_key (
"piv_tol");
5538 if (! octave::math::isnan (tmp))
5540 Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
5541 Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
5545 tmp = octave::sparse_params::get_key (
"autoamd");
5546 if (! octave::math::isnan (tmp))
5547 Control (UMFPACK_FIXQ) = tmp;
5558 octave::to_suitesparse_intptr (Ap),
5559 octave::to_suitesparse_intptr (Ai),
5560 reinterpret_cast<const double *
> (Ax),
5561 nullptr, 1, control);
5564 Info =
Matrix (1, UMFPACK_INFO);
5565 double *info = Info.
rwdata ();
5567 octave::to_suitesparse_intptr (Ap),
5568 octave::to_suitesparse_intptr (Ai),
5569 reinterpret_cast<const double *
> (Ax),
5570 nullptr,
nullptr, &Symbolic, control, info);
5580 (*current_liboctave_error_handler)
5581 (
"SparseComplexMatrix::solve symbolic factorization failed");
5588 status =
UMFPACK_ZNAME (numeric) (octave::to_suitesparse_intptr (Ap),
5589 octave::to_suitesparse_intptr (Ai),
5590 reinterpret_cast<const double *
> (Ax),
5591 nullptr, Symbolic, &Numeric, control, info);
5595 rcond = Info (UMFPACK_RCOND);
5599 if (status == UMFPACK_WARNING_singular_matrix
5600 || is_singular (rcond) || octave::math::isnan (rcond))
5607 sing_handler (rcond);
5609 octave::warn_singular_matrix (rcond);
5611 else if (status < 0)
5617 (*current_liboctave_error_handler)
5618 (
"SparseComplexMatrix::solve numeric factorization failed");
5633 octave_unused_parameter (rcond);
5634 octave_unused_parameter (Control);
5635 octave_unused_parameter (Info);
5636 octave_unused_parameter (sing_handler);
5637 octave_unused_parameter (calc_cond);
5639 (*current_liboctave_error_handler)
5640 (
"support for UMFPACK was unavailable or disabled when liboctave was built");
5650 solve_singularity_handler sing_handler,
5651 bool calc_cond)
const
5659 if (nr != nc || nr != b.
rows ())
5660 (*current_liboctave_error_handler)
5661 (
"matrix dimension mismatch solution of linear equations");
5663 if (nr == 0 || b.
cols () == 0)
5668 int typ = mattype.
type ();
5673#if defined (HAVE_CHOLMOD)
5674 cholmod_common Common;
5675 cholmod_common *cm = &Common;
5679 cm->prefer_zomplex =
false;
5681 double spu = octave::sparse_params::get_key (
"spumoni");
5685 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
nullptr);
5689 cm->print =
static_cast<int> (spu) + 2;
5690 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &
SparseCholPrint);
5694 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex);
5695 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
5697 cm->final_ll =
true;
5699 cholmod_sparse Astore;
5700 cholmod_sparse *
A = &Astore;
5710#if defined (OCTAVE_ENABLE_64)
5711 A->itype = CHOLMOD_LONG;
5713 A->itype = CHOLMOD_INT;
5715 A->dtype = CHOLMOD_DOUBLE;
5717 A->xtype = CHOLMOD_COMPLEX;
5721 cholmod_dense Bstore;
5722 cholmod_dense *
B = &Bstore;
5723 B->nrow = b.
rows ();
5724 B->ncol = b.
cols ();
5726 B->nzmax =
B->nrow *
B->ncol;
5727 B->dtype = CHOLMOD_DOUBLE;
5728 B->xtype = CHOLMOD_REAL;
5730 B->x =
const_cast<double *
> (b.
data ());
5747 if (is_singular (rcond) || octave::math::isnan (rcond))
5753 sing_handler (rcond);
5757 octave::warn_singular_matrix (rcond);
5769 retval.
xelem (i, j) =
static_cast<Complex *
> (X->x)[jr + i];
5775 static char blank_name[] =
" ";
5779 (*current_liboctave_warning_with_id_handler)
5780 (
"Octave:missing-dependency",
5781 "support for CHOLMOD was unavailable or disabled "
5782 "when liboctave was built");
5791#if defined (HAVE_UMFPACK)
5793 void *Numeric = factorize (err, rcond, Control, Info,
5794 sing_handler, calc_cond);
5799 Control (UMFPACK_IRSTEP) = 1;
5803 double *control = Control.
rwdata ();
5804 double *info = Info.
rwdata ();
5808#if defined (UMFPACK_SEPARATE_SPLIT)
5809 const double *Bx = b.
data ();
5816 retval.
resize (b_nr, b_nc);
5821#if defined (UMFPACK_SEPARATE_SPLIT)
5823 octave::to_suitesparse_intptr (Ap),
5824 octave::to_suitesparse_intptr (Ai),
5825 reinterpret_cast<const double *
> (Ax),
5827 reinterpret_cast<double *
> (&Xx[iidx]),
5829 &Bx[iidx], Bz, Numeric,
5833 Bz[i] = b.
elem (i, j);
5836 octave::to_suitesparse_intptr (Ap),
5837 octave::to_suitesparse_intptr (Ai),
5838 reinterpret_cast<const double *
> (Ax),
5840 reinterpret_cast<double *
> (&Xx[iidx]),
5842 reinterpret_cast<const double *
> (Bz),
5852 (*current_liboctave_error_handler)
5853 (
"SparseComplexMatrix::solve solve failed");
5868 octave_unused_parameter (rcond);
5869 octave_unused_parameter (sing_handler);
5870 octave_unused_parameter (calc_cond);
5872 (*current_liboctave_error_handler)
5873 (
"support for UMFPACK was unavailable or disabled "
5874 "when liboctave was built");
5878 (*current_liboctave_error_handler) (
"incorrect matrix type");
5887 solve_singularity_handler sing_handler,
5888 bool calc_cond)
const
5896 if (nr != nc || nr != b.
rows ())
5897 (*current_liboctave_error_handler)
5898 (
"matrix dimension mismatch solution of linear equations");
5900 if (nr == 0 || b.
cols () == 0)
5905 int typ = mattype.
type ();
5910#if defined (HAVE_CHOLMOD)
5911 cholmod_common Common;
5912 cholmod_common *cm = &Common;
5916 cm->prefer_zomplex =
false;
5918 double spu = octave::sparse_params::get_key (
"spumoni");
5922 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
nullptr);
5926 cm->print =
static_cast<int> (spu) + 2;
5927 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &
SparseCholPrint);
5931 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex);
5932 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
5934 cm->final_ll =
true;
5936 cholmod_sparse Astore;
5937 cholmod_sparse *
A = &Astore;
5947#if defined (OCTAVE_ENABLE_64)
5948 A->itype = CHOLMOD_LONG;
5950 A->itype = CHOLMOD_INT;
5952 A->dtype = CHOLMOD_DOUBLE;
5954 A->xtype = CHOLMOD_COMPLEX;
5958 cholmod_sparse Bstore;
5959 cholmod_sparse *
B = &Bstore;
5960 B->nrow = b.
rows ();
5961 B->ncol = b.
cols ();
5964 B->nzmax = b.
nnz ();
5968#if defined (OCTAVE_ENABLE_64)
5969 B->itype = CHOLMOD_LONG;
5971 B->itype = CHOLMOD_INT;
5973 B->dtype = CHOLMOD_DOUBLE;
5975 B->xtype = CHOLMOD_REAL;
5994 if (is_singular (rcond) || octave::math::isnan (rcond))
6000 sing_handler (rcond);
6004 octave::warn_singular_matrix (rcond);
6009 cholmod_sparse *X =
CHOLMOD_NAME(spsolve) (CHOLMOD_A, L,
B, cm);
6012 (octave::from_size_t (X->nrow),
6013 octave::from_size_t (X->ncol),
6017 j <= static_cast<octave_idx_type> (X->ncol); j++)
6030 static char blank_name[] =
" ";
6034 (*current_liboctave_warning_with_id_handler)
6035 (
"Octave:missing-dependency",
6036 "support for CHOLMOD was unavailable or disabled "
6037 "when liboctave was built");
6046#if defined (HAVE_UMFPACK)
6048 void *Numeric = factorize (err, rcond, Control, Info,
6049 sing_handler, calc_cond);
6054 Control (UMFPACK_IRSTEP) = 1;
6058 double *control = Control.
rwdata ();
6059 double *info = Info.
rwdata ();
6064#if defined (UMFPACK_SEPARATE_SPLIT)
6081 retval.
xcidx (0) = 0;
6085#if defined (UMFPACK_SEPARATE_SPLIT)
6087 Bx[i] = b.
elem (i, j);
6090 octave::to_suitesparse_intptr (Ap),
6091 octave::to_suitesparse_intptr (Ai),
6092 reinterpret_cast<const double *
> (Ax),
6094 reinterpret_cast<double *
> (Xx),
6096 Bx, Bz, Numeric, control,
6100 Bz[i] = b.
elem (i, j);
6103 octave::to_suitesparse_intptr (Ap),
6104 octave::to_suitesparse_intptr (Ai),
6105 reinterpret_cast<const double *
> (Ax),
6107 reinterpret_cast<double *
> (Xx),
6109 reinterpret_cast<double *
> (Bz),
6119 (*current_liboctave_error_handler)
6120 (
"SparseComplexMatrix::solve solve failed");
6135 sz = (
static_cast<double> (b_nc) - j) / b_nc
6137 sz = x_nz + (sz > 100 ? sz : 100);
6141 retval.
xdata (ii) = tmp;
6142 retval.
xridx (ii++) = i;
6145 retval.
xcidx (j+1) = ii;
6158 octave_unused_parameter (rcond);
6159 octave_unused_parameter (sing_handler);
6160 octave_unused_parameter (calc_cond);
6162 (*current_liboctave_error_handler)
6163 (
"support for UMFPACK was unavailable or disabled "
6164 "when liboctave was built");
6168 (*current_liboctave_error_handler) (
"incorrect matrix type");
6177 solve_singularity_handler sing_handler,
6178 bool calc_cond)
const
6186 if (nr != nc || nr != b.
rows ())
6187 (*current_liboctave_error_handler)
6188 (
"matrix dimension mismatch solution of linear equations");
6190 if (nr == 0 || b.
cols () == 0)
6195 int typ = mattype.
type ();
6200#if defined (HAVE_CHOLMOD)
6201 cholmod_common Common;
6202 cholmod_common *cm = &Common;
6206 cm->prefer_zomplex =
false;
6208 double spu = octave::sparse_params::get_key (
"spumoni");
6212 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
nullptr);
6216 cm->print =
static_cast<int> (spu) + 2;
6217 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &
SparseCholPrint);
6221 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex);
6222 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
6224 cm->final_ll =
true;
6226 cholmod_sparse Astore;
6227 cholmod_sparse *
A = &Astore;
6237#if defined (OCTAVE_ENABLE_64)
6238 A->itype = CHOLMOD_LONG;
6240 A->itype = CHOLMOD_INT;
6242 A->dtype = CHOLMOD_DOUBLE;
6244 A->xtype = CHOLMOD_COMPLEX;
6248 cholmod_dense Bstore;
6249 cholmod_dense *
B = &Bstore;
6250 B->nrow = b.
rows ();
6251 B->ncol = b.
cols ();
6253 B->nzmax =
B->nrow *
B->ncol;
6254 B->dtype = CHOLMOD_DOUBLE;
6255 B->xtype = CHOLMOD_COMPLEX;
6274 if (is_singular (rcond) || octave::math::isnan (rcond))
6280 sing_handler (rcond);
6284 octave::warn_singular_matrix (rcond);
6296 retval.
xelem (i, j) =
static_cast<Complex *
> (X->x)[jr + i];
6302 static char blank_name[] =
" ";
6306 (*current_liboctave_warning_with_id_handler)
6307 (
"Octave:missing-dependency",
6308 "support for CHOLMOD was unavailable or disabled "
6309 "when liboctave was built");
6318#if defined (HAVE_UMFPACK)
6320 void *Numeric = factorize (err, rcond, Control, Info,
6321 sing_handler, calc_cond);
6326 Control (UMFPACK_IRSTEP) = 1;
6330 double *control = Control.
rwdata ();
6331 double *info = Info.
rwdata ();
6337 retval.
resize (b_nr, b_nc);
6344 octave::to_suitesparse_intptr (Ap),
6345 octave::to_suitesparse_intptr (Ai),
6346 reinterpret_cast<const double *
> (Ax),
6348 reinterpret_cast<double *
> (&Xx[iidx]),
6350 reinterpret_cast<const double *
> (&Bx[iidx]),
6351 nullptr, Numeric, control, info);
6358 (*current_liboctave_error_handler)
6359 (
"SparseComplexMatrix::solve solve failed");
6374 octave_unused_parameter (rcond);
6375 octave_unused_parameter (sing_handler);
6376 octave_unused_parameter (calc_cond);
6378 (*current_liboctave_error_handler)
6379 (
"support for UMFPACK was unavailable or disabled "
6380 "when liboctave was built");
6384 (*current_liboctave_error_handler) (
"incorrect matrix type");
6393 solve_singularity_handler sing_handler,
6394 bool calc_cond)
const
6402 if (nr != nc || nr != b.
rows ())
6403 (*current_liboctave_error_handler)
6404 (
"matrix dimension mismatch solution of linear equations");
6406 if (nr == 0 || b.
cols () == 0)
6411 int typ = mattype.
type ();
6416#if defined (HAVE_CHOLMOD)
6417 cholmod_common Common;
6418 cholmod_common *cm = &Common;
6422 cm->prefer_zomplex =
false;
6424 double spu = octave::sparse_params::get_key (
"spumoni");
6428 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
nullptr);
6432 cm->print =
static_cast<int> (spu) + 2;
6433 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &
SparseCholPrint);
6437 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex);
6438 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
6440 cm->final_ll =
true;
6442 cholmod_sparse Astore;
6443 cholmod_sparse *
A = &Astore;
6453#if defined (OCTAVE_ENABLE_64)
6454 A->itype = CHOLMOD_LONG;
6456 A->itype = CHOLMOD_INT;
6458 A->dtype = CHOLMOD_DOUBLE;
6460 A->xtype = CHOLMOD_COMPLEX;
6464 cholmod_sparse Bstore;
6465 cholmod_sparse *
B = &Bstore;
6466 B->nrow = b.
rows ();
6467 B->ncol = b.
cols ();
6470 B->nzmax = b.
nnz ();
6474#if defined (OCTAVE_ENABLE_64)
6475 B->itype = CHOLMOD_LONG;
6477 B->itype = CHOLMOD_INT;
6479 B->dtype = CHOLMOD_DOUBLE;
6481 B->xtype = CHOLMOD_COMPLEX;
6500 if (is_singular (rcond) || octave::math::isnan (rcond))
6506 sing_handler (rcond);
6510 octave::warn_singular_matrix (rcond);
6515 cholmod_sparse *X =
CHOLMOD_NAME(spsolve) (CHOLMOD_A, L,
B, cm);
6518 (octave::from_size_t (X->nrow),
6519 octave::from_size_t (X->ncol),
6523 j <= static_cast<octave_idx_type> (X->ncol); j++)
6536 static char blank_name[] =
" ";
6540 (*current_liboctave_warning_with_id_handler)
6541 (
"Octave:missing-dependency",
6542 "support for CHOLMOD was unavailable or disabled "
6543 "when liboctave was built");
6552#if defined (HAVE_UMFPACK)
6554 void *Numeric = factorize (err, rcond, Control, Info,
6555 sing_handler, calc_cond);
6560 Control (UMFPACK_IRSTEP) = 1;
6564 double *control = Control.
rwdata ();
6565 double *info = Info.
rwdata ();
6580 retval.
xcidx (0) = 0;
6587 octave::to_suitesparse_intptr (Ap),
6588 octave::to_suitesparse_intptr (Ai),
6589 reinterpret_cast<const double *
> (Ax),
6591 reinterpret_cast<double *
> (Xx),
6593 reinterpret_cast<double *
> (Bx),
6594 nullptr, Numeric, control, info);
6601 (*current_liboctave_error_handler)
6602 (
"SparseComplexMatrix::solve solve failed");
6617 sz = (
static_cast<double> (b_nc) - j) / b_nc
6619 sz = x_nz + (sz > 100 ? sz : 100);
6623 retval.
xdata (ii) = tmp;
6624 retval.
xridx (ii++) = i;
6627 retval.
xcidx (j+1) = ii;
6632 rcond = Info (UMFPACK_RCOND);
6633 if (status == UMFPACK_WARNING_singular_matrix
6634 || is_singular (rcond) || octave::math::isnan (rcond))
6639 sing_handler (rcond);
6641 octave::warn_singular_matrix (rcond);
6652 octave_unused_parameter (rcond);
6653 octave_unused_parameter (sing_handler);
6654 octave_unused_parameter (calc_cond);
6656 (*current_liboctave_error_handler)
6657 (
"support for UMFPACK was unavailable or disabled "
6658 "when liboctave was built");
6662 (*current_liboctave_error_handler) (
"incorrect matrix type");
6673 return solve (mattype, b, info, rcond,
nullptr);
6681 return solve (mattype, b, info, rcond,
nullptr);
6688 return solve (mattype, b, info, rcond,
nullptr);
6694 solve_singularity_handler sing_handler,
6695 bool singular_fallback)
const
6698 int typ = mattype.
type (
false);
6701 typ = mattype.
type (*
this);
6704 retval = dsolve (mattype, b, err, rcond, sing_handler,
false);
6706 retval = utsolve (mattype, b, err, rcond, sing_handler,
false);
6708 retval = ltsolve (mattype, b, err, rcond, sing_handler,
false);
6710 retval = bsolve (mattype, b, err, rcond, sing_handler,
false);
6713 retval = trisolve (mattype, b, err, rcond, sing_handler,
false);
6715 retval = fsolve (mattype, b, err, rcond, sing_handler,
true);
6717 (*current_liboctave_error_handler) (
"unknown matrix type");
6734 return solve (mattype, b, info, rcond,
nullptr);
6742 return solve (mattype, b, info, rcond,
nullptr);
6749 return solve (mattype, b, info, rcond,
nullptr);
6755 solve_singularity_handler sing_handler,
6756 bool singular_fallback)
const
6759 int typ = mattype.
type (
false);
6762 typ = mattype.
type (*
this);
6765 retval = dsolve (mattype, b, err, rcond, sing_handler,
false);
6767 retval = utsolve (mattype, b, err, rcond, sing_handler,
false);
6769 retval = ltsolve (mattype, b, err, rcond, sing_handler,
false);
6771 retval = bsolve (mattype, b, err, rcond, sing_handler,
false);
6774 retval = trisolve (mattype, b, err, rcond, sing_handler,
false);
6776 retval = fsolve (mattype, b, err, rcond, sing_handler,
true);
6778 (*current_liboctave_error_handler) (
"unknown matrix type");
6795 return solve (mattype, b, info, rcond,
nullptr);
6803 return solve (mattype, b, info, rcond,
nullptr);
6810 return solve (mattype, b, info, rcond,
nullptr);
6816 solve_singularity_handler sing_handler,
6817 bool singular_fallback)
const
6820 int typ = mattype.
type (
false);
6823 typ = mattype.
type (*
this);
6826 retval = dsolve (mattype, b, err, rcond, sing_handler,
false);
6828 retval = utsolve (mattype, b, err, rcond, sing_handler,
false);
6830 retval = ltsolve (mattype, b, err, rcond, sing_handler,
false);
6832 retval = bsolve (mattype, b, err, rcond, sing_handler,
false);
6835 retval = trisolve (mattype, b, err, rcond, sing_handler,
false);
6837 retval = fsolve (mattype, b, err, rcond, sing_handler,
true);
6839 (*current_liboctave_error_handler) (
"unknown matrix type");
6857 return solve (mattype, b, info, rcond,
nullptr);
6865 return solve (mattype, b, info, rcond,
nullptr);
6872 return solve (mattype, b, info, rcond,
nullptr);
6878 solve_singularity_handler sing_handler,
6879 bool singular_fallback)
const
6882 int typ = mattype.
type (
false);
6885 typ = mattype.
type (*
this);
6888 retval = dsolve (mattype, b, err, rcond, sing_handler,
false);
6890 retval = utsolve (mattype, b, err, rcond, sing_handler,
false);
6892 retval = ltsolve (mattype, b, err, rcond, sing_handler,
false);
6894 retval = bsolve (mattype, b, err, rcond, sing_handler,
false);
6897 retval = trisolve (mattype, b, err, rcond, sing_handler,
false);
6899 retval = fsolve (mattype, b, err, rcond, sing_handler,
true);
6901 (*current_liboctave_error_handler) (
"unknown matrix type");
6917 return solve (mattype, b, info, rcond);
6925 return solve (mattype, b, info, rcond);
6932 return solve (mattype, b, info, rcond,
nullptr);
6938 solve_singularity_handler sing_handler)
const
6941 return solve (mattype, tmp, info, rcond,
6951 return solve (mattype, b, info, rcond,
nullptr);
6959 return solve (mattype, b, info, rcond,
nullptr);
6966 return solve (mattype, b, info, rcond,
nullptr);
6972 solve_singularity_handler sing_handler)
const
6975 return solve (mattype, tmp, info, rcond,
6984 return solve (b, info, rcond,
nullptr);
6991 return solve (b, info, rcond,
nullptr);
6996 double& rcond)
const
6998 return solve (b, info, rcond,
nullptr);
7004 solve_singularity_handler sing_handler)
const
7007 return solve (mattype, b, err, rcond, sing_handler);
7015 return solve (b, info, rcond,
nullptr);
7023 return solve (b, info, rcond,
nullptr);
7030 return solve (b, info, rcond,
nullptr);
7036 solve_singularity_handler sing_handler)
const
7039 return solve (mattype, b, err, rcond, sing_handler);
7047 return solve (b, info, rcond,
nullptr);
7054 return solve (b, info, rcond,
nullptr);
7060 solve_singularity_handler sing_handler)
const
7063 return solve (mattype, b, err, rcond, sing_handler);
7071 return solve (b, info, rcond,
nullptr);
7079 return solve (b, info, rcond,
nullptr);
7086 return solve (b, info, rcond,
nullptr);
7092 solve_singularity_handler sing_handler)
const
7095 return solve (mattype, b, err, rcond, sing_handler);
7102 return solve (b, info, rcond);
7109 return solve (b, info, rcond);
7114 double& rcond)
const
7116 return solve (b, info, rcond,
nullptr);
7122 solve_singularity_handler sing_handler)
const
7125 return solve (tmp, info, rcond,
7134 return solve (b, info, rcond,
nullptr);
7142 return solve (b, info, rcond,
nullptr);
7147 double& rcond)
const
7149 return solve (b, info, rcond,
nullptr);
7155 solve_singularity_handler sing_handler)
const
7158 return solve (tmp, info, rcond,
7167 octave::err_nan_to_logical_conversion ();
7183 if (jj <
cidx (i+1) &&
ridx (jj) == j)
7231 if (octave::math::isnan (val))
7246 if (octave::math::isinf (val) || octave::math::isnan (val))
7273 max_val = std::real (
data (0));
7274 min_val = std::real (
data (0));
7280 double r_val = val.real ();
7281 double i_val = val.imag ();
7283 if (r_val > max_val)
7286 if (i_val > max_val)
7289 if (r_val < min_val)
7292 if (i_val < min_val)
7295 if (octave::math::x_nint (r_val) != r_val
7296 || octave::math::x_nint (i_val) != i_val)
7306 return test_any (octave::too_large_for_float);
7338 if ((
rows () == 1 && dim == -1) || dim == 1)
7343 (
cidx (j+1) -
cidx (j) < nr ? 0.0 : 1.0), 1.0);
7357 Complex d = data (i); \
7358 tmp[ridx (i)] += d * conj (d)
7361 Complex d = data (i); \
7362 tmp[j] += d * conj (d)
7384 retval.
data (i) = std::abs (
data (i));
7409 os << a.
ridx (i) + 1 <<
' ' << j + 1 <<
' ';
7410 octave::write_value<Complex> (os, a.
data (i));
7423 return read_sparse_matrix<elt_type> (is, a, octave::read_value<Complex>);
7508 return do_mul_dm_sm<SparseComplexMatrix> (
d, a);
7513 return do_mul_sm_dm<SparseComplexMatrix> (a,
d);
7519 return do_mul_dm_sm<SparseComplexMatrix> (
d, a);
7524 return do_mul_sm_dm<SparseComplexMatrix> (a,
d);
7530 return do_mul_dm_sm<SparseComplexMatrix> (
d, a);
7535 return do_mul_sm_dm<SparseComplexMatrix> (a,
d);
7541 return do_add_dm_sm<SparseComplexMatrix> (
d, a);
7546 return do_add_dm_sm<SparseComplexMatrix> (
d, a);
7551 return do_add_dm_sm<SparseComplexMatrix> (
d, a);
7556 return do_add_sm_dm<SparseComplexMatrix> (a,
d);
7561 return do_add_sm_dm<SparseComplexMatrix> (a,
d);
7566 return do_add_sm_dm<SparseComplexMatrix> (a,
d);
7572 return do_sub_dm_sm<SparseComplexMatrix> (
d, a);
7577 return do_sub_dm_sm<SparseComplexMatrix> (
d, a);
7582 return do_sub_dm_sm<SparseComplexMatrix> (
d, a);
7587 return do_sub_sm_dm<SparseComplexMatrix> (a,
d);
7592 return do_sub_sm_dm<SparseComplexMatrix> (a,
d);
7597 return do_sub_sm_dm<SparseComplexMatrix> (a,
d);
7616#define EMPTY_RETURN_CHECK(T) \
7617 if (nr == 0 || nc == 0) \
7638 result.
data (i) = octave::math::min (c, m.
data (i));
7660 if (a_nr == b_nr && a_nc == b_nc)
7670 bool ja_lt_max = ja < ja_max;
7674 bool jb_lt_max = jb < jb_max;
7676 while (ja_lt_max || jb_lt_max)
7679 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
7681 Complex tmp = octave::math::min (a.
data (ja), 0.);
7689 ja_lt_max= ja < ja_max;
7691 else if ((! ja_lt_max)
7692 || (jb_lt_max && (b.
ridx (jb) < a.
ridx (ja))))
7694 Complex tmp = octave::math::min (0., b.
data (jb));
7702 jb_lt_max= jb < jb_max;
7714 ja_lt_max= ja < ja_max;
7716 jb_lt_max= jb < jb_max;
7726 if (a_nr == 0 || a_nc == 0)
7728 else if (b_nr == 0 || b_nc == 0)
7731 octave::err_nonconformant (
"min", a_nr, a_nc, b_nr, b_nc);
7748 if (octave::math::max (c, 0.) != 0.)
7753 result.
xdata (m.
ridx (i) + j * nr) = octave::math::max (c, m.
data (i));
7777 if (a_nr == b_nr && a_nc == b_nc)
7787 bool ja_lt_max = ja < ja_max;
7791 bool jb_lt_max = jb < jb_max;
7793 while (ja_lt_max || jb_lt_max)
7796 if ((! jb_lt_max) || (ja_lt_max && (a.
ridx (ja) < b.
ridx (jb))))
7798 Complex tmp = octave::math::max (a.
data (ja), 0.);
7806 ja_lt_max= ja < ja_max;
7808 else if ((! ja_lt_max)
7809 || (jb_lt_max && (b.
ridx (jb) < a.
ridx (ja))))
7811 Complex tmp = octave::math::max (0., b.
data (jb));
7819 jb_lt_max= jb < jb_max;
7831 ja_lt_max= ja < ja_max;
7833 jb_lt_max= jb < jb_max;
7843 if (a_nr == 0 || a_nc == 0)
7845 else if (b_nr == 0 || b_nc == 0)
7848 octave::err_nonconformant (
"max", a_nr, a_nc, b_nr, b_nc);
SparseComplexMatrix max(const Complex &c, const SparseComplexMatrix &m)
SparseComplexMatrix operator-(const ComplexDiagMatrix &d, const SparseMatrix &a)
SparseComplexMatrix conj(const SparseComplexMatrix &a)
ComplexMatrix mul_trans(const ComplexMatrix &m, const SparseComplexMatrix &a)
SparseComplexMatrix operator*(const SparseComplexMatrix &m, const SparseMatrix &a)
#define EMPTY_RETURN_CHECK(T)
ComplexMatrix mul_herm(const ComplexMatrix &m, const SparseComplexMatrix &a)
SparseComplexMatrix min(const Complex &c, const SparseComplexMatrix &m)
std::ostream & operator<<(std::ostream &os, const SparseComplexMatrix &a)
SparseComplexMatrix operator+(const ComplexDiagMatrix &d, const SparseMatrix &a)
ComplexMatrix trans_mul(const SparseComplexMatrix &m, const ComplexMatrix &a)
std::istream & operator>>(std::istream &is, SparseComplexMatrix &a)
ComplexMatrix herm_mul(const SparseComplexMatrix &m, const ComplexMatrix &a)
base_det< Complex > ComplexDET
#define SPARSE_SSM_BOOL_OPS(S, M)
#define SPARSE_ANY_OP(DIM)
#define SPARSE_BASE_REDUCTION_OP(RET_TYPE, EL_TYPE, ROW_EXPR, COL_EXPR, INIT_VAL, MT_RESULT)
#define SPARSE_FULL_MUL(RET_TYPE, EL_TYPE)
#define FULL_SPARSE_MUL_TRANS(RET_TYPE, EL_TYPE, CONJ_OP)
#define SPARSE_SSM_CMP_OPS(S, M)
#define SPARSE_SMSM_CMP_OPS(M1, M2)
#define SPARSE_REDUCTION_OP(RET_TYPE, EL_TYPE, OP, INIT_VAL, MT_RESULT)
#define SPARSE_SMS_CMP_OPS(M, S)
#define SPARSE_SPARSE_MUL(RET_TYPE, RET_EL_TYPE, EL_TYPE)
#define SPARSE_CUMSUM(RET_TYPE, ELT_TYPE, FCN)
#define SPARSE_CUMPROD(RET_TYPE, ELT_TYPE, FCN)
#define SPARSE_FULL_TRANS_MUL(RET_TYPE, EL_TYPE, CONJ_OP)
#define FULL_SPARSE_MUL(RET_TYPE, EL_TYPE)
#define SPARSE_SMSM_BOOL_OPS(M1, M2)
#define SPARSE_SMS_BOOL_OPS(M, S)
#define SPARSE_ALL_OP(DIM)
SM octinternal_do_mul_pm_sm(const PermMatrix &p, const SM &a)
SM octinternal_do_mul_sm_pm(const SM &a, const PermMatrix &p)
N Dimensional Array with copy-on-write semantics.
T & xelem(octave_idx_type n)
Size of the specified dimension.
T & elem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type rows() const
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type cols() const
const T * data() const
Size of the specified dimension.
T * rwdata()
Size of the specified dimension.
void resize(octave_idx_type nr, octave_idx_type nc, const Complex &rfv=Complex(0))
ComplexColumnVector column(octave_idx_type i) const
octave_idx_type length() const
octave_idx_type cols() const
MSparse< T > diag(octave_idx_type k=0) const
MSparse< T > & insert(const Sparse< T > &a, octave_idx_type r, octave_idx_type c)
MSparse< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
MSparse< T > reshape(const dim_vector &new_dims) const
MSparse< T > squeeze() const
MSparse< T > ipermute(const Array< octave_idx_type > &vec) const
void mark_as_unsymmetric()
octave_idx_type * triangular_perm() const
MatrixType transpose() const
int type(bool quiet=true)
void mark_as_rectangular()
SparseComplexMatrix min(int dim=-1) const
ComplexRowVector row(octave_idx_type i) const
bool too_large_for_float() const
bool any_element_is_inf_or_nan() const
friend SparseComplexMatrix conj(const SparseComplexMatrix &a)
SparseComplexMatrix hermitian() const
SparseComplexMatrix sumsq(int dim=-1) const
SparseComplexMatrix diag(octave_idx_type k=0) const
ComplexColumnVector column(octave_idx_type i) const
ComplexMatrix matrix_value() const
bool all_elements_are_real() const
SparseComplexMatrix & insert(const SparseComplexMatrix &a, octave_idx_type r, octave_idx_type c)
SparseComplexMatrix max(int dim=-1) const
bool any_element_is_nan() const
SparseComplexMatrix inverse() const
bool all_integers(double &max_val, double &min_val) const
SparseComplexMatrix reshape(const dim_vector &new_dims) const
SparseComplexMatrix permute(const Array< octave_idx_type > &vec, bool inv=false) const
bool operator!=(const SparseComplexMatrix &a) const
SparseBoolMatrix any(int dim=-1) const
SparseComplexMatrix prod(int dim=-1) const
SparseComplexMatrix sum(int dim=-1) const
SparseComplexMatrix transpose() const
SparseComplexMatrix ipermute(const Array< octave_idx_type > &vec) const
bool operator==(const SparseComplexMatrix &a) const
SparseComplexMatrix concat(const SparseComplexMatrix &rb, const Array< octave_idx_type > &ra_idx)
SparseComplexMatrix squeeze() const
ComplexDET determinant() const
SparseBoolMatrix operator!() const
ComplexMatrix solve(MatrixType &mattype, const Matrix &b) const
SparseComplexMatrix cumsum(int dim=-1) const
SparseComplexMatrix cumprod(int dim=-1) const
SparseBoolMatrix all(int dim=-1) const
octave_idx_type cols() const
Array< T > array_value() const
octave_idx_type columns() const
void resize(octave_idx_type r, octave_idx_type c)
bool test_any(F fcn) const
T & elem(octave_idx_type n)
Sparse< T, Alloc > maybe_compress(bool remove_zeros=false)
octave_idx_type nnz() const
Actual number of nonzero terms.
octave_idx_type rows() const
void change_capacity(octave_idx_type nz)
octave_idx_type * xcidx()
octave_idx_type * xridx()
Vector representing the dimensions (size) of an Array.
octave_idx_type ndims() const
Number of dimensions.
int first_non_singleton(int def=0) const
#define F77_DBLE_CMPLX_ARG(x)
#define F77_XFCN(f, F, args)
octave_f77_int_type F77_INT
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
#define liboctave_panic_unless(cond)
F77_RET_T const F77_INT F77_CMPLX const F77_INT F77_CMPLX * B
F77_RET_T const F77_INT const F77_INT const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE * Q
F77_RET_T const F77_INT F77_CMPLX * A
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
bool mx_inline_all_real(std::size_t n, const std::complex< T > *x)
std::complex< double > Complex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
#define UMFPACK_ZNAME(name)
#define CHOLMOD_NAME(name)
const octave_base_value const Array< octave_idx_type > & ra_idx
template int8_t abs(int8_t)
template ComplexMatrix dmsolve< ComplexMatrix, SparseComplexMatrix, ComplexMatrix >(const SparseComplexMatrix &, const ComplexMatrix &, octave_idx_type &)
template ComplexMatrix dmsolve< ComplexMatrix, SparseComplexMatrix, Matrix >(const SparseComplexMatrix &, const Matrix &, octave_idx_type &)
RT dmsolve(const ST &a, const T &b, octave_idx_type &info)
template SparseComplexMatrix dmsolve< SparseComplexMatrix, SparseComplexMatrix, SparseMatrix >(const SparseComplexMatrix &, const SparseMatrix &, octave_idx_type &)
void SparseCholError(int status, char *file, int line, char *message)
int SparseCholPrint(const char *fmt,...)