26#if defined (HAVE_CONFIG_H)
144 elem (i, j) =
static_cast<unsigned char> (a.
elem (i, j));
151 (*current_liboctave_error_handler) (
"complex: internal error");
170 return !(*
this == a);
200 if (r < 0 || r + a_nr >
rows () || c < 0 || c + a_nc >
cols ())
201 (*current_liboctave_error_handler) (
"range error for insert");
203 if (a_nr >0 && a_nc > 0)
220 if (r < 0 || r >=
rows () || c < 0 || c + a_len >
cols ())
221 (*current_liboctave_error_handler) (
"range error for insert");
240 if (r < 0 || r + a_len >
rows () || c < 0 || c >=
cols ())
241 (*current_liboctave_error_handler) (
"range error for insert");
261 if (r < 0 || r + a_nr >
rows () || c < 0 || c + a_nc >
cols ())
262 (*current_liboctave_error_handler) (
"range error for insert");
264 fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1);
292 if (r < 0 || r >=
rows () || c < 0 || c + a_len >
cols ())
293 (*current_liboctave_error_handler) (
"range error for insert");
307 if (r < 0 || r + a_len >
rows () || c < 0 || c >=
cols ())
308 (*current_liboctave_error_handler) (
"range error for insert");
328 if (r < 0 || r + a_nr >
rows () || c < 0 || c + a_nc >
cols ())
329 (*current_liboctave_error_handler) (
"range error for insert");
331 fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1);
352 if (nr > 0 && nc > 0)
370 if (nr > 0 && nc > 0)
389 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0
390 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc)
391 (*current_liboctave_error_handler) (
"range error for fill");
393 if (r1 > r2) { std::swap (r1, r2); }
394 if (c1 > c2) { std::swap (c1, c2); }
396 if (r2 >= r1 && c2 >= c1)
415 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0
416 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc)
417 (*current_liboctave_error_handler) (
"range error for fill");
419 if (r1 > r2) { std::swap (r1, r2); }
420 if (c1 > c2) { std::swap (c1, c2); }
422 if (r2 >= r1 && c2 >=c1)
440 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
444 retval.
insert (*
this, 0, 0);
445 retval.
insert (a, 0, nc_insert);
455 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
459 retval.
insert (*
this, 0, 0);
460 retval.
insert (a, 0, nc_insert);
469 if (nr != a.
numel ())
470 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
474 retval.
insert (*
this, 0, 0);
475 retval.
insert (a, 0, nc_insert);
485 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
489 retval.
insert (*
this, 0, 0);
490 retval.
insert (a, 0, nc_insert);
500 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
504 retval.
insert (*
this, 0, 0);
505 retval.
insert (a, 0, nc_insert);
515 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
519 retval.
insert (*
this, 0, 0);
520 retval.
insert (a, 0, nc_insert);
529 if (nr != a.
numel ())
530 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
534 retval.
insert (*
this, 0, 0);
535 retval.
insert (a, 0, nc_insert);
545 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
549 retval.
insert (*
this, 0, 0);
550 retval.
insert (a, 0, nc_insert);
560 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
564 retval.
insert (*
this, 0, 0);
565 retval.
insert (a, nr_insert, 0);
574 if (nc != a.
numel ())
575 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
579 retval.
insert (*
this, 0, 0);
580 retval.
insert (a, nr_insert, 0);
590 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
594 retval.
insert (*
this, 0, 0);
595 retval.
insert (a, nr_insert, 0);
605 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
609 retval.
insert (*
this, 0, 0);
610 retval.
insert (a, nr_insert, 0);
620 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
624 retval.
insert (*
this, 0, 0);
625 retval.
insert (a, nr_insert, 0);
634 if (nc != a.
numel ())
635 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
639 retval.
insert (*
this, 0, 0);
640 retval.
insert (a, nr_insert, 0);
650 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
654 retval.
insert (*
this, 0, 0);
655 retval.
insert (a, nr_insert, 0);
665 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
669 retval.
insert (*
this, 0, 0);
670 retval.
insert (a, nr_insert, 0);
677 return do_mx_unary_map<Complex, Complex, std::conj<double>> (a);
686 if (r1 > r2) { std::swap (r1, r2); }
687 if (c1 > c2) { std::swap (c1, c2); }
723 double sum = colsum.
xelem (i);
742 return inverse (mattype, info, rcon, 0, 0);
750 return inverse (mattype, info, rcon, 0, 0);
755 bool calc_cond)
const
758 return inverse (mattype, info, rcon, force, calc_cond);
766 return inverse (mattype, info, rcon, 0, 0);
773 return inverse (mattype, info, rcon, 0, 0);
778 double& rcon,
bool force,
bool calc_cond)
const
785 if (nr != nc || nr == 0 || nc == 0)
786 (*current_liboctave_error_handler) (
"inverse requires square matrix");
788 int typ = mattype.
type ();
796 F77_XFCN (ztrtri, ZTRTRI, (F77_CONST_CHAR_ARG2 (&uplo, 1),
797 F77_CONST_CHAR_ARG2 (&udiag, 1),
800 F77_CHAR_ARG_LEN (1)));
816 F77_XFCN (ztrcon, ZTRCON, (F77_CONST_CHAR_ARG2 (&job, 1),
817 F77_CONST_CHAR_ARG2 (&uplo, 1),
818 F77_CONST_CHAR_ARG2 (&udiag, 1),
823 F77_CHAR_ARG_LEN (1)));
825 if (ztrcon_info != 0)
829 if (info == -1 && ! force)
837 double& rcon,
bool force,
bool calc_cond)
const
845 (*current_liboctave_error_handler) (
"inverse requires square matrix");
848 F77_INT *pipvt = ipvt.fortran_vec ();
865 lwork = (lwork < 2 * nc ? 2 * nc : lwork);
873 double anorm =
norm1 (retval);
899 F77_XFCN (zgecon, ZGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
902 F77_CHAR_ARG_LEN (1)));
904 if (zgecon_info != 0)
908 if ((info == -1 && ! force)
918 if (zgetri_info != 0)
930 double& rcon,
bool force,
bool calc_cond)
const
932 int typ = mattype.
type (
false);
936 typ = mattype.
type (*
this);
948 ret =
Complex (1, 0) / (*this);
963 ret =
tinverse (mattype, info, rcon, force, calc_cond);
972 rcon =
chol.rcond ();
975 ret =
chol.inverse ();
982 ret =
finverse (mattype, info, rcon, force, calc_cond);
984 if ((calc_cond || mattype.
ishermitian ()) && rcon == 0.0)
1015 * std::numeric_limits<double>::epsilon ();
1021 while (r >= 0 && sigma.
elem (r) < tol)
1037#if defined (HAVE_FFTW)
1042 std::size_t nr =
rows ();
1043 std::size_t nc =
cols ();
1047 std::size_t npts, nsamples;
1049 if (nr == 1 || nc == 1)
1051 npts = (nr > nc ? nr : nc);
1071 std::size_t nr =
rows ();
1072 std::size_t nc =
cols ();
1076 std::size_t npts, nsamples;
1078 if (nr == 1 || nc == 1)
1080 npts = (nr > nc ? nr : nc);
1130 (*current_liboctave_error_handler)
1131 (
"support for FFTW was unavailable or disabled when liboctave was built");
1139 (*current_liboctave_error_handler)
1140 (
"support for FFTW was unavailable or disabled when liboctave was built");
1148 (*current_liboctave_error_handler)
1149 (
"support for FFTW was unavailable or disabled when liboctave was built");
1157 (*current_liboctave_error_handler)
1158 (
"support for FFTW was unavailable or disabled when liboctave was built");
1182 bool calc_cond)
const
1185 return determinant (mattype, info, rcon, calc_cond);
1191 bool calc_cond)
const
1202 (*current_liboctave_error_handler) (
"matrix must be square");
1204 volatile int typ = mattype.
type ();
1211 typ = mattype.
type (*
this);
1217 for (
F77_INT i = 0; i < nc; i++)
1218 retval *=
elem (i, i);
1227 anorm =
norm1 (*
this);
1232 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1234 F77_CHAR_ARG_LEN (1)));
1253 F77_XFCN (zpocon, ZPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1256 F77_CHAR_ARG_LEN (1)));
1264 for (
F77_INT i = 0; i < nc; i++)
1265 retval *= atmp(i, i);
1267 retval = retval.
square ();
1271 (*current_liboctave_error_handler) (
"det: invalid dense matrix type");
1284 double anorm =
norm1 (*
this);
1317 F77_XFCN (zgecon, ZGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1320 F77_CHAR_ARG_LEN (1)));
1332 for (
F77_INT i = 0; i < nc; i++)
1335 retval *= (ipvt(i) != (i+1)) ? -c : c;
1348 return rcond (mattype);
1359 (*current_liboctave_error_handler) (
"matrix must be square");
1361 if (nr == 0 || nc == 0)
1365 volatile int typ = mattype.
type ();
1368 typ = mattype.
type (*
this);
1384 F77_XFCN (ztrcon, ZTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1385 F77_CONST_CHAR_ARG2 (&uplo, 1),
1386 F77_CONST_CHAR_ARG2 (&dia, 1),
1389 F77_CHAR_ARG_LEN (1)
1390 F77_CHAR_ARG_LEN (1)
1391 F77_CHAR_ARG_LEN (1)));
1397 (*current_liboctave_error_handler)
1398 (
"permuted triangular matrix not implemented");
1412 F77_XFCN (ztrcon, ZTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1413 F77_CONST_CHAR_ARG2 (&uplo, 1),
1414 F77_CONST_CHAR_ARG2 (&dia, 1),
1417 F77_CHAR_ARG_LEN (1)
1418 F77_CHAR_ARG_LEN (1)
1419 F77_CHAR_ARG_LEN (1)));
1425 (*current_liboctave_error_handler)
1426 (
"permuted triangular matrix not implemented");
1429 double anorm = -1.0;
1439 anorm =
norm1 (atmp);
1441 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1443 F77_CHAR_ARG_LEN (1)));
1459 F77_XFCN (zpocon, ZPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1462 F77_CHAR_ARG_LEN (1)));
1480 anorm =
norm1 (atmp);
1503 F77_XFCN (zgecon, ZGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1506 F77_CHAR_ARG_LEN (1)));
1523 solve_singularity_handler sing_handler,
1535 (*current_liboctave_error_handler)
1536 (
"matrix dimension mismatch solution of linear equations");
1538 if (nr == 0 || nc == 0 || b_nc == 0)
1542 volatile int typ = mattype.
type ();
1545 (*current_liboctave_error_handler) (
"incorrect matrix type");
1551 (*current_liboctave_error_handler)
1552 (
"permuted triangular matrix not implemented");
1565 F77_XFCN (ztrtrs, ZTRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1566 F77_CONST_CHAR_ARG2 (&trans, 1),
1567 F77_CONST_CHAR_ARG2 (&dia, 1),
1570 F77_CHAR_ARG_LEN (1)
1571 F77_CHAR_ARG_LEN (1)
1572 F77_CHAR_ARG_LEN (1)));
1587 F77_XFCN (ztrcon, ZTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1588 F77_CONST_CHAR_ARG2 (&uplo, 1),
1589 F77_CONST_CHAR_ARG2 (&dia, 1),
1592 F77_CHAR_ARG_LEN (1)
1593 F77_CHAR_ARG_LEN (1)
1594 F77_CHAR_ARG_LEN (1)));
1601 volatile double rcond_plus_one = rcon + 1.0;
1608 sing_handler (rcon);
1621 solve_singularity_handler sing_handler,
1633 (*current_liboctave_error_handler)
1634 (
"matrix dimension mismatch solution of linear equations");
1636 if (nr == 0 || nc == 0 || b_nc == 0)
1640 volatile int typ = mattype.
type ();
1643 (*current_liboctave_error_handler) (
"incorrect matrix type");
1649 (*current_liboctave_error_handler)
1650 (
"permuted triangular matrix not implemented");
1663 F77_XFCN (ztrtrs, ZTRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1664 F77_CONST_CHAR_ARG2 (&trans, 1),
1665 F77_CONST_CHAR_ARG2 (&dia, 1),
1668 F77_CHAR_ARG_LEN (1)
1669 F77_CHAR_ARG_LEN (1)
1670 F77_CHAR_ARG_LEN (1)));
1685 F77_XFCN (ztrcon, ZTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1686 F77_CONST_CHAR_ARG2 (&uplo, 1),
1687 F77_CONST_CHAR_ARG2 (&dia, 1),
1690 F77_CHAR_ARG_LEN (1)
1691 F77_CHAR_ARG_LEN (1)
1692 F77_CHAR_ARG_LEN (1)));
1699 volatile double rcond_plus_one = rcon + 1.0;
1706 sing_handler (rcon);
1719 solve_singularity_handler sing_handler,
1720 bool calc_cond)
const
1730 if (nr != nc || nr != b_nr)
1731 (*current_liboctave_error_handler)
1732 (
"matrix dimension mismatch solution of linear equations");
1734 if (nr == 0 || b_nc == 0)
1738 volatile int typ = mattype.
type ();
1741 double anorm = -1.0;
1753 anorm =
norm1 (atmp);
1757 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1759 F77_CHAR_ARG_LEN (1)));
1781 F77_XFCN (zpocon, ZPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1784 F77_CHAR_ARG_LEN (1)));
1791 volatile double rcond_plus_one = rcon + 1.0;
1798 sing_handler (rcon);
1809 F77_XFCN (zpotrs, ZPOTRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1812 F77_CHAR_ARG_LEN (1)));
1840 if (calc_cond && anorm < 0.0)
1841 anorm =
norm1 (atmp);
1852 nr, pipvt, tmp_info));
1864 sing_handler (rcon);
1876 F77_XFCN (zgecon, ZGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1879 F77_CHAR_ARG_LEN (1)));
1886 volatile double rcond_plus_one = rcon + 1.0;
1891 sing_handler (rcon);
1903 F77_XFCN (zgetrs, ZGETRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1906 F77_CHAR_ARG_LEN (1)));
1930 return solve (mattype, b, info, rcon,
nullptr);
1938 return solve (mattype, b, info, rcon,
nullptr);
1945 return solve (mattype, b, info, rcon,
nullptr);
1951 solve_singularity_handler sing_handler,
1955 return solve (mattype, tmp, info, rcon, sing_handler, singular_fallback,
1964 return solve (mattype, b, info, rcon,
nullptr);
1972 return solve (mattype, b, info, rcon,
nullptr);
1979 return solve (mattype, b, info, rcon,
nullptr);
1985 solve_singularity_handler sing_handler,
1989 int typ = mattype.
type ();
1992 typ = mattype.
type (*
this);
1996 retval =
utsolve (mattype, b, info, rcon, sing_handler,
true, transt);
1998 retval =
ltsolve (mattype, b, info, rcon, sing_handler,
true, transt);
2003 retval =
hermitian ().
solve (mattype, b, info, rcon, sing_handler,
2006 retval =
fsolve (mattype, b, info, rcon, sing_handler,
true);
2008 (*current_liboctave_error_handler) (
"unknown matrix type");
2014 retval =
lssolve (b, info, rank, rcon);
2046 solve_singularity_handler sing_handler,
2058 return solve (mattype, b, info, rcon,
nullptr);
2066 return solve (mattype, b, info, rcon,
nullptr);
2073 return solve (mattype, b, info, rcon,
nullptr);
2079 solve_singularity_handler sing_handler,
2084 tmp =
solve (mattype, tmp, info, rcon, sing_handler,
true, transt);
2093 return solve (b, info, rcon,
nullptr);
2100 return solve (b, info, rcon,
nullptr);
2107 return solve (b, info, rcon,
nullptr);
2112 solve_singularity_handler sing_handler,
2116 return solve (tmp, info, rcon, sing_handler, transt);
2124 return solve (b, info, rcon,
nullptr);
2131 return solve (b, info, rcon,
nullptr);
2138 return solve (b, info, rcon,
nullptr);
2144 solve_singularity_handler sing_handler,
2148 return solve (mattype, b, info, rcon, sing_handler,
true, transt);
2176 solve_singularity_handler sing_handler,
2187 return solve (b, info, rcon,
nullptr);
2194 return solve (b, info, rcon,
nullptr);
2201 return solve (b, info, rcon,
nullptr);
2207 solve_singularity_handler sing_handler,
2211 return solve (mattype, b, info, rcon, sing_handler, transt);
2252 return lssolve (b, info, rank, rcon);
2260 return lssolve (b, info, rank, rcon);
2268 return lssolve (b, info, rank, rcon);
2285 (*current_liboctave_error_handler)
2286 (
"matrix dimension mismatch solution of linear equations");
2288 if (m == 0 || n == 0 || b_nc == 0)
2292 volatile F77_INT minmn = (m < n ? m : n);
2293 F77_INT maxmn = (m > n ? m : n);
2300 for (
F77_INT j = 0; j < nrhs; j++)
2301 for (
F77_INT i = 0; i < m; i++)
2302 retval.
elem (i, j) = b.
elem (i, j);
2321 F77_CONST_CHAR_ARG2 (
" ", 1),
2323 F77_CHAR_ARG_LEN (6)
2324 F77_CHAR_ARG_LEN (1));
2328 F77_CONST_CHAR_ARG2 (
" ", 1),
2329 m, n, nrhs, -1, mnthr
2330 F77_CHAR_ARG_LEN (6)
2331 F77_CHAR_ARG_LEN (1));
2336 double dminmn =
static_cast<double> (minmn);
2337 double dsmlsizp1 =
static_cast<double> (smlsiz+1);
2344 F77_INT lrwork = minmn*(10 + 2*smlsiz + 8*nlvl)
2347 n*(1+nrhs) + 2*nrhs);
2353 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2365 lwork, prwork, piwork, tmp_info));
2374 if (n > m && n >= mnthr)
2387 const F77_INT lworkaround = 4*m + m*m + addend;
2390 work(0) = lworkaround;
2394 F77_INT lworkaround = 2*m + m*nrhs;
2397 work(0) = lworkaround;
2403 double anorm =
norm1 (*
this);
2420 maxmn, ps, rcon, tmp_rank,
2422 lwork, prwork, piwork, tmp_info));
2427 if (s.
elem (0) == 0.0)
2430 rcon = s.
elem (minmn - 1) / s.
elem (0);
2477 return lssolve (b, info, rank, rcon);
2486 return lssolve (b, info, rank, rcon);
2494 return lssolve (b, info, rank, rcon);
2512 (*current_liboctave_error_handler)
2513 (
"matrix dimension mismatch solution of linear equations");
2515 if (m == 0 || n == 0)
2519 volatile F77_INT minmn = (m < n ? m : n);
2520 F77_INT maxmn = (m > n ? m : n);
2527 for (
F77_INT i = 0; i < m; i++)
2547 F77_CONST_CHAR_ARG2 (
" ", 1),
2549 F77_CHAR_ARG_LEN (6)
2550 F77_CHAR_ARG_LEN (1));
2555 double dminmn =
static_cast<double> (minmn);
2556 double dsmlsizp1 =
static_cast<double> (smlsiz+1);
2563 F77_INT lrwork = minmn*(10 + 2*smlsiz + 8*nlvl)
2564 + 3*smlsiz*nrhs + (smlsiz+1)*(smlsiz+1);
2570 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2582 lwork, prwork, piwork, tmp_info));
2594 maxmn, ps, rcon, tmp_rank,
2596 prwork, piwork, tmp_info));
2603 if (s.
elem (0) == 0.0)
2606 rcon = s.
elem (minmn - 1) / s.
elem (0);
2645 F77_XFCN (zgemm, ZGEMM, (F77_CONST_CHAR_ARG2 (
"N", 1),
2646 F77_CONST_CHAR_ARG2 (
"N", 1),
2649 F77_CHAR_ARG_LEN (1)
2650 F77_CHAR_ARG_LEN (1)));
2667 if (nr != a_nr || nc != a_nc)
2685 if (nr != a_nr || nc != a_nc)
2703 if (nr != a_nr || nc != a_nc)
2721 if (nr != a_nr || nc != a_nc)
2741 if (nr != a_nr || nc != a_nc)
2744 if (nr == 0 || nc == 0)
2762 if (nr != a_nr || nc != a_nc)
2765 if (nr == 0 || nc == 0)
2836 if (nr != 1 && nc != 1)
2837 (*current_liboctave_error_handler) (
"diag: expecting vector argument");
2895 if (nr > 0 && nc > 0)
2910 for (idx_j = 0; idx_j < nc; idx_j++)
2912 tmp_min =
elem (i, idx_j);
2916 abs_min = (real_only ? tmp_min.real ()
2929 double abs_tmp = (real_only ? tmp.real () :
std::abs (tmp));
2931 if (abs_tmp < abs_min)
2942 idx_arg.
elem (i) = 0;
2946 result.
elem (i) = tmp_min;
2947 idx_arg.
elem (i) = idx_j;
2970 if (nr > 0 && nc > 0)
2985 for (idx_j = 0; idx_j < nc; idx_j++)
2987 tmp_max =
elem (i, idx_j);
2991 abs_max = (real_only ? tmp_max.real ()
3004 double abs_tmp = (real_only ? tmp.real () :
std::abs (tmp));
3006 if (abs_tmp > abs_max)
3017 idx_arg.
elem (i) = 0;
3021 result.
elem (i) = tmp_max;
3022 idx_arg.
elem (i) = idx_j;
3045 if (nr > 0 && nc > 0)
3060 for (idx_i = 0; idx_i < nr; idx_i++)
3062 tmp_min =
elem (idx_i, j);
3066 abs_min = (real_only ? tmp_min.real ()
3079 double abs_tmp = (real_only ? tmp.real () :
std::abs (tmp));
3081 if (abs_tmp < abs_min)
3092 idx_arg.
elem (j) = 0;
3096 result.
elem (j) = tmp_min;
3097 idx_arg.
elem (j) = idx_i;
3120 if (nr > 0 && nc > 0)
3135 for (idx_i = 0; idx_i < nr; idx_i++)
3137 tmp_max =
elem (idx_i, j);
3141 abs_max = (real_only ? tmp_max.real ()
3154 double abs_tmp = (real_only ? tmp.real () :
std::abs (tmp));
3156 if (abs_tmp > abs_max)
3167 idx_arg.
elem (j) = 0;
3171 result.
elem (j) = tmp_max;
3172 idx_arg.
elem (j) = idx_i;
3190 octave::write_value<Complex> (os, a.
elem (i, j));
3203 if (nr > 0 && nc > 0)
3209 tmp = octave::read_value<Complex> (is);
3211 a.
elem (i, j) = tmp;
3277 F77_XFCN (ztrsyl, ZTRSYL, (F77_CONST_CHAR_ARG2 (
"N", 1),
3278 F77_CONST_CHAR_ARG2 (
"N", 1),
3281 F77_CHAR_ARG_LEN (1)
3282 F77_CHAR_ARG_LEN (1)));
3335 return trans ? (
conj ?
'C' :
'T') :
'N';
3360 if (a_nr == 0 || a_nc == 0 || b_nc == 0)
3362 else if (a.
data () == b.
data () && a_nr == b_nc && tra != trb)
3377 F77_XFCN (zherk, ZHERK, (F77_CONST_CHAR_ARG2 (
"U", 1),
3378 F77_CONST_CHAR_ARG2 (&ctra, 1),
3381 F77_CHAR_ARG_LEN (1)
3382 F77_CHAR_ARG_LEN (1)));
3383 for (
F77_INT j = 0; j < a_nr; j++)
3384 for (
F77_INT i = 0; i < j; i++)
3389 F77_XFCN (zsyrk, ZSYRK, (F77_CONST_CHAR_ARG2 (
"U", 1),
3390 F77_CONST_CHAR_ARG2 (&ctra, 1),
3393 F77_CHAR_ARG_LEN (1)
3394 F77_CHAR_ARG_LEN (1)));
3395 for (
F77_INT j = 0; j < a_nr; j++)
3396 for (
F77_INT i = 0; i < j; i++)
3412 if (b_nc == 1 && a_nr == 1)
3430 else if (b_nc == 1 && ! cjb)
3433 F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 (&ctra, 1),
3436 F77_CHAR_ARG_LEN (1)));
3438 else if (a_nr == 1 && ! cja && ! cjb)
3441 F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 (&crevtrb, 1),
3444 F77_CHAR_ARG_LEN (1)));
3450 F77_XFCN (zgemm, ZGEMM, (F77_CONST_CHAR_ARG2 (&ctra, 1),
3451 F77_CONST_CHAR_ARG2 (&ctrb, 1),
3455 F77_CHAR_ARG_LEN (1)
3456 F77_CHAR_ARG_LEN (1)));
3466 return xgemm (a, b);
3471#define EMPTY_RETURN_CHECK(T) \
3472 if (nr == 0 || nc == 0) \
3508 (*current_liboctave_error_handler)
3509 (
"two-arg min requires same size arguments");
3517 bool columns_are_real_only =
true;
3523 columns_are_real_only =
false;
3528 if (columns_are_real_only)
3580 (*current_liboctave_error_handler)
3581 (
"two-arg max requires same size arguments");
3589 bool columns_are_real_only =
true;
3595 columns_are_real_only =
false;
3601 if (columns_are_real_only)
3629 if (x2.
numel () != m)
3630 (*current_liboctave_error_handler)
3631 (
"linspace: vectors must be of equal length");
3637 retval.
clear (m, 0);
3641 retval.clear (m, n);
3643 retval.xelem (i, 0) = x1(i);
3646 Complex *delta = &retval.xelem (0, n-1);
3648 delta[i] = (x1(i) == x2(i)) ? 0 : (x2(i) - x1(i)) / (n - 1.0);
3652 retval.xelem (i, j) = x1(i) +
static_cast<double> (j)*delta[i];
3655 retval.
xelem (i, n-1) = x2(i);
static double norm1(const ComplexMatrix &a)
std::ostream & operator<<(std::ostream &os, const ComplexMatrix &a)
ComplexMatrix max(const Complex &c, const ComplexMatrix &m)
ComplexMatrix Givens(const Complex &x, const Complex &y)
static const Complex Complex_NaN_result(octave::numeric_limits< double >::NaN(), octave::numeric_limits< double >::NaN())
ComplexMatrix conj(const ComplexMatrix &a)
static char get_blas_trans_arg(bool trans, bool conj)
ComplexMatrix linspace(const ComplexColumnVector &x1, const ComplexColumnVector &x2, octave_idx_type n)
ComplexMatrix Sylvester(const ComplexMatrix &a, const ComplexMatrix &b, const ComplexMatrix &c)
ComplexMatrix min(const Complex &c, const ComplexMatrix &m)
#define EMPTY_RETURN_CHECK(T)
ComplexMatrix operator*(const ColumnVector &v, const ComplexRowVector &a)
ComplexMatrix xgemm(const ComplexMatrix &a, const ComplexMatrix &b, blas_trans_type transa, blas_trans_type transb)
std::istream & operator>>(std::istream &is, ComplexMatrix &a)
base_det< Complex > ComplexDET
N Dimensional Array with copy-on-write semantics.
bool issquare(void) const
Complex & xelem(octave_idx_type n)
OCTARRAY_API void clear(void)
OCTARRAY_API Array< Complex, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type cols(void) const
Complex & elem(octave_idx_type n)
octave_idx_type rows(void) const
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type columns(void) const
const Complex * data(void) const
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
OCTAVE_API ColumnVector extract(octave_idx_type r1, octave_idx_type r2) const
void resize(octave_idx_type n, const Complex &rfv=Complex(0))
OCTAVE_API Matrix abs(void) const
ComplexMatrix(void)=default
ComplexMatrix fsolve(MatrixType &mattype, const ComplexMatrix &b, octave_idx_type &info, double &rcon, solve_singularity_handler sing_handler, bool calc_cond=false) const
OCTAVE_API ComplexMatrix & operator+=(const DiagMatrix &a)
OCTAVE_API ComplexMatrix & operator-=(const DiagMatrix &a)
OCTAVE_API ComplexMatrix lssolve(const Matrix &b) const
OCTAVE_API ComplexMatrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
OCTAVE_API ComplexColumnVector row_max(void) const
OCTAVE_API boolMatrix all(int dim=-1) const
OCTAVE_API ComplexMatrix & fill(double val)
OCTAVE_API ComplexMatrix fourier2d(void) const
OCTAVE_API ComplexRowVector column_min(void) const
OCTAVE_API ComplexColumnVector row_min(void) const
ComplexMatrix finverse(MatrixType &mattype, octave_idx_type &info, double &rcon, bool force, bool calc_cond) const
OCTAVE_API ComplexMatrix append(const Matrix &a) const
OCTAVE_API double rcond(void) const
OCTAVE_API ComplexMatrix diag(octave_idx_type k=0) const
ComplexMatrix transpose(void) const
ComplexMatrix hermitian(void) const
OCTAVE_API ComplexMatrix pseudo_inverse(double tol=0.0) const
OCTAVE_API bool operator==(const ComplexMatrix &a) const
OCTAVE_API ComplexMatrix inverse(void) const
OCTAVE_API bool ishermitian(void) const
OCTAVE_API ComplexDET determinant(void) const
OCTAVE_API ComplexMatrix ifourier(void) const
OCTAVE_API ComplexMatrix ifourier2d(void) const
OCTAVE_API ComplexRowVector row(octave_idx_type i) const
ComplexMatrix ltsolve(MatrixType &mattype, const ComplexMatrix &b, octave_idx_type &info, double &rcon, solve_singularity_handler sing_handler, bool calc_cond=false, blas_trans_type transt=blas_no_trans) const
OCTAVE_API ComplexMatrix & insert(const Matrix &a, octave_idx_type r, octave_idx_type c)
OCTAVE_API ComplexMatrix solve(MatrixType &mattype, const Matrix &b) const
OCTAVE_API ComplexRowVector column_max(void) const
friend OCTAVE_API ComplexMatrix conj(const ComplexMatrix &a)
OCTAVE_API bool row_is_real_only(octave_idx_type) const
OCTAVE_API ComplexMatrix sumsq(int dim=-1) const
void resize(octave_idx_type nr, octave_idx_type nc, const Complex &rfv=Complex(0))
OCTAVE_API ComplexMatrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
OCTAVE_API ComplexMatrix stack(const Matrix &a) const
OCTAVE_API ComplexMatrix cumprod(int dim=-1) const
OCTAVE_API ComplexMatrix fourier(void) const
OCTAVE_API ComplexMatrix prod(int dim=-1) const
OCTAVE_API ComplexMatrix cumsum(int dim=-1) const
ComplexMatrix tinverse(MatrixType &mattype, octave_idx_type &info, double &rcon, bool force, bool calc_cond) const
OCTAVE_API boolMatrix any(int dim=-1) const
OCTAVE_API bool operator!=(const ComplexMatrix &a) const
OCTAVE_API bool column_is_real_only(octave_idx_type) const
ComplexMatrix utsolve(MatrixType &mattype, const ComplexMatrix &b, octave_idx_type &info, double &rcon, solve_singularity_handler sing_handler, bool calc_cond=false, blas_trans_type transt=blas_no_trans) const
OCTAVE_API ComplexMatrix sum(int dim=-1) const
OCTAVE_API ComplexColumnVector column(octave_idx_type i) const
OCTAVE_API boolNDArray any(int dim=-1) const
OCTAVE_API ComplexNDArray prod(int dim=-1) const
OCTAVE_API ComplexNDArray sumsq(int dim=-1) const
OCTAVE_API ComplexNDArray diag(octave_idx_type k=0) const
OCTAVE_API ComplexNDArray cumsum(int dim=-1) const
OCTAVE_API ComplexNDArray & insert(const NDArray &a, octave_idx_type r, octave_idx_type c)
OCTAVE_API NDArray abs(void) const
OCTAVE_API ComplexNDArray cumprod(int dim=-1) const
OCTAVE_API boolNDArray all(int dim=-1) const
OCTAVE_API ComplexNDArray sum(int dim=-1) const
void resize(octave_idx_type n, const Complex &rfv=Complex(0))
T elem(octave_idx_type r, octave_idx_type c) const
octave_idx_type length(void) const
octave_idx_type cols(void) const
octave_idx_type rows(void) const
ColumnVector extract_diag(octave_idx_type k=0) const
bool ishermitian(void) const
void mark_as_rectangular(void)
OCTAVE_API void mark_as_unsymmetric(void)
OCTAVE_API int type(bool quiet=true)
OCTAVE_API Matrix sum(int dim=-1) const
OCTAVE_API RowVector row(octave_idx_type i) const
Vector representing the dimensions (size) of an Array.
static int ifft(const Complex *in, Complex *out, std::size_t npts, std::size_t nsamples=1, octave_idx_type stride=1, octave_idx_type dist=-1)
static int fftNd(const double *, Complex *, const int, const dim_vector &)
static int ifftNd(const Complex *, Complex *, const int, const dim_vector &)
static int fft(const double *in, Complex *out, std::size_t npts, std::size_t nsamples=1, octave_idx_type stride=1, octave_idx_type dist=-1)
static const idx_vector colon
T unitary_schur_matrix(void) const
T schur_matrix(void) const
DM_T singular_values(void) const
T right_singular_matrix(void) const
T left_singular_matrix(void) const
ColumnVector real(const ComplexColumnVector &a)
ColumnVector imag(const ComplexColumnVector &a)
#define F77_DBLE_CMPLX_ARG(x)
#define F77_XFCN(f, F, args)
octave_f77_int_type F77_INT
#define F77_CONST_DBLE_CMPLX_ARG(x)
double norm(const ColumnVector &v)
void scale(Matrix &m, double x, double y, double z)
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE * x
char get_blas_char(blas_trans_type transt)
class OCTAVE_API ComplexDiagMatrix
class OCTAVE_API DiagMatrix
class OCTAVE_API ComplexMatrix
class OCTAVE_API ComplexColumnVector
void mx_inline_sub2(std::size_t n, R *r, const X *x)
void mx_inline_add2(std::size_t n, R *r, const X *x)
bool mx_inline_equal(std::size_t n, const T1 *x, const T2 *y)
#define MM_BOOL_OPS(M1, M2)
#define MM_CMP_OPS(M1, M2)
#define SM_BOOL_OPS(S, M)
#define MS_BOOL_OPS(M, S)
Complex log2(const Complex &x)
void warn_singular_matrix(double rcond)
void err_nonconformant(const char *op, octave_idx_type op1_len, octave_idx_type op2_len)
std::complex< double > Complex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
static bool scalar(const dim_vector &dims)
F77_RET_T F77_FUNC(xerbla, XERBLA)(F77_CONST_CHAR_ARG_DEF(s_arg
subroutine xilaenv(ispec, name, opts, n1, n2, n3, n4, retval)
subroutine xzdotc(n, zx, incx, zy, incy, retval)
subroutine xzdotu(n, zx, incx, zy, incy, retval)