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);
867 Complex *pz = z.fortran_vec ();
873 double anorm = norm1 (retval);
902 double *prz = rz.fortran_vec ();
903 F77_XFCN (zgecon, ZGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
906 zgecon_info F77_CHAR_ARG_LEN (1)));
908 if (zgecon_info != 0)
913 if ((info == -1 && ! force)
923 if (zgetri_info != 0)
935 double& rcon,
bool force,
bool calc_cond)
const
937 int typ = mattype.
type (
false);
941 typ = mattype.
type (*
this);
953 ret =
Complex (1, 0) / (*this);
968 ret = tinverse (mattype, info, rcon, force, calc_cond);
973 octave::math::chol<ComplexMatrix>
chol (*
this, info,
true, calc_cond);
987 ret = finverse (mattype, info, rcon, force, calc_cond);
989 if ((calc_cond || mattype.
ishermitian ()) && rcon == 0.0)
1004 octave::math::svd<ComplexMatrix> result (*
this,
1005 octave::math::svd<ComplexMatrix>::Type::economy);
1020 * std::numeric_limits<double>::epsilon ();
1026 while (
r >= 0 && sigma.
elem (
r) < tol)
1042 #if defined (HAVE_FFTW)
1047 std::size_t nr =
rows ();
1048 std::size_t nc =
cols ();
1052 std::size_t npts, nsamples;
1054 if (nr == 1 || nc == 1)
1056 npts = (nr > nc ? nr : nc);
1068 octave::fftw::fft (in, out, npts, nsamples);
1076 std::size_t nr =
rows ();
1077 std::size_t nc =
cols ();
1081 std::size_t npts, nsamples;
1083 if (nr == 1 || nc == 1)
1085 npts = (nr > nc ? nr : nc);
1097 octave::fftw::ifft (in, out, npts, nsamples);
1111 octave::fftw::fftNd (in, out, 2, dv);
1125 octave::fftw::ifftNd (in, out, 2, dv);
1135 (*current_liboctave_error_handler)
1136 (
"support for FFTW was unavailable or disabled when liboctave was built");
1144 (*current_liboctave_error_handler)
1145 (
"support for FFTW was unavailable or disabled when liboctave was built");
1153 (*current_liboctave_error_handler)
1154 (
"support for FFTW was unavailable or disabled when liboctave was built");
1162 (*current_liboctave_error_handler)
1163 (
"support for FFTW was unavailable or disabled when liboctave was built");
1187 bool calc_cond)
const
1190 return determinant (mattype, info, rcon, calc_cond);
1196 bool calc_cond)
const
1207 (*current_liboctave_error_handler) (
"matrix must be square");
1209 volatile int typ = mattype.
type ();
1216 typ = mattype.
type (*
this);
1222 for (
F77_INT i = 0; i < nc; i++)
1223 retval *=
elem (i, i);
1232 anorm = norm1 (*
this);
1237 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1239 F77_CHAR_ARG_LEN (1)));
1258 F77_XFCN (zpocon, ZPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1261 F77_CHAR_ARG_LEN (1)));
1269 for (
F77_INT i = 0; i < nc; i++)
1270 retval *= atmp(i, i);
1272 retval = retval.
square ();
1276 (*current_liboctave_error_handler) (
"det: invalid dense matrix type");
1289 double anorm = norm1 (*
this);
1322 F77_XFCN (zgecon, ZGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1325 F77_CHAR_ARG_LEN (1)));
1337 for (
F77_INT i = 0; i < nc; i++)
1340 retval *= (ipvt(i) != (i+1)) ? -c : c;
1353 return rcond (mattype);
1364 (*current_liboctave_error_handler) (
"matrix must be square");
1366 if (nr == 0 || nc == 0)
1370 volatile int typ = mattype.
type ();
1373 typ = mattype.
type (*
this);
1389 F77_XFCN (ztrcon, ZTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1390 F77_CONST_CHAR_ARG2 (&uplo, 1),
1391 F77_CONST_CHAR_ARG2 (&dia, 1),
1394 F77_CHAR_ARG_LEN (1)
1395 F77_CHAR_ARG_LEN (1)
1396 F77_CHAR_ARG_LEN (1)));
1402 (*current_liboctave_error_handler)
1403 (
"permuted triangular matrix not implemented");
1417 F77_XFCN (ztrcon, ZTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1418 F77_CONST_CHAR_ARG2 (&uplo, 1),
1419 F77_CONST_CHAR_ARG2 (&dia, 1),
1422 F77_CHAR_ARG_LEN (1)
1423 F77_CHAR_ARG_LEN (1)
1424 F77_CHAR_ARG_LEN (1)));
1430 (*current_liboctave_error_handler)
1431 (
"permuted triangular matrix not implemented");
1434 double anorm = -1.0;
1444 anorm = norm1 (atmp);
1446 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1448 F77_CHAR_ARG_LEN (1)));
1464 F77_XFCN (zpocon, ZPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1467 F77_CHAR_ARG_LEN (1)));
1485 anorm = norm1 (atmp);
1508 F77_XFCN (zgecon, ZGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1511 F77_CHAR_ARG_LEN (1)));
1528 solve_singularity_handler sing_handler,
1540 (*current_liboctave_error_handler)
1541 (
"matrix dimension mismatch solution of linear equations");
1543 if (nr == 0 || nc == 0 || b_nc == 0)
1547 volatile int typ = mattype.
type ();
1550 (*current_liboctave_error_handler) (
"incorrect matrix type");
1556 (*current_liboctave_error_handler)
1557 (
"permuted triangular matrix not implemented");
1570 F77_XFCN (ztrtrs, ZTRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1571 F77_CONST_CHAR_ARG2 (&trans, 1),
1572 F77_CONST_CHAR_ARG2 (&dia, 1),
1575 F77_CHAR_ARG_LEN (1)
1576 F77_CHAR_ARG_LEN (1)
1577 F77_CHAR_ARG_LEN (1)));
1588 Complex *pz = z.fortran_vec ();
1590 double *prz = rz.fortran_vec ();
1592 F77_XFCN (ztrcon, ZTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1593 F77_CONST_CHAR_ARG2 (&uplo, 1),
1594 F77_CONST_CHAR_ARG2 (&dia, 1),
1597 F77_CHAR_ARG_LEN (1)
1598 F77_CHAR_ARG_LEN (1)
1599 F77_CHAR_ARG_LEN (1)));
1606 volatile double rcond_plus_one = rcon + 1.0;
1613 sing_handler (rcon);
1626 solve_singularity_handler sing_handler,
1638 (*current_liboctave_error_handler)
1639 (
"matrix dimension mismatch solution of linear equations");
1641 if (nr == 0 || nc == 0 || b_nc == 0)
1645 volatile int typ = mattype.
type ();
1648 (*current_liboctave_error_handler) (
"incorrect matrix type");
1654 (*current_liboctave_error_handler)
1655 (
"permuted triangular matrix not implemented");
1668 F77_XFCN (ztrtrs, ZTRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1669 F77_CONST_CHAR_ARG2 (&trans, 1),
1670 F77_CONST_CHAR_ARG2 (&dia, 1),
1673 F77_CHAR_ARG_LEN (1)
1674 F77_CHAR_ARG_LEN (1)
1675 F77_CHAR_ARG_LEN (1)));
1686 Complex *pz = z.fortran_vec ();
1688 double *prz = rz.fortran_vec ();
1690 F77_XFCN (ztrcon, ZTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1691 F77_CONST_CHAR_ARG2 (&uplo, 1),
1692 F77_CONST_CHAR_ARG2 (&dia, 1),
1695 F77_CHAR_ARG_LEN (1)
1696 F77_CHAR_ARG_LEN (1)
1697 F77_CHAR_ARG_LEN (1)));
1704 volatile double rcond_plus_one = rcon + 1.0;
1711 sing_handler (rcon);
1724 solve_singularity_handler sing_handler,
1725 bool calc_cond)
const
1735 if (nr != nc || nr != b_nr)
1736 (*current_liboctave_error_handler)
1737 (
"matrix dimension mismatch solution of linear equations");
1739 if (nr == 0 || b_nc == 0)
1743 volatile int typ = mattype.
type ();
1746 double anorm = -1.0;
1758 anorm = norm1 (atmp);
1762 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1764 F77_CHAR_ARG_LEN (1)));
1782 Complex *pz = z.fortran_vec ();
1784 double *prz = rz.fortran_vec ();
1786 F77_XFCN (zpocon, ZPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1789 F77_CHAR_ARG_LEN (1)));
1796 volatile double rcond_plus_one = rcon + 1.0;
1803 sing_handler (rcon);
1814 F77_XFCN (zpotrs, ZPOTRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1817 F77_CHAR_ARG_LEN (1)));
1834 F77_INT *pipvt = ipvt.fortran_vec ();
1840 Complex *pz = z.fortran_vec ();
1842 double *prz = rz.fortran_vec ();
1845 if (calc_cond && anorm < 0.0)
1846 anorm = norm1 (atmp);
1857 nr, pipvt, tmp_info));
1869 sing_handler (rcon);
1881 F77_XFCN (zgecon, ZGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1884 F77_CHAR_ARG_LEN (1)));
1891 volatile double rcond_plus_one = rcon + 1.0;
1896 sing_handler (rcon);
1908 F77_XFCN (zgetrs, ZGETRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1911 F77_CHAR_ARG_LEN (1)));
1935 return solve (mattype, b, info, rcon,
nullptr);
1943 return solve (mattype, b, info, rcon,
nullptr);
1950 return solve (mattype, b, info, rcon,
nullptr);
1956 solve_singularity_handler sing_handler,
1960 return solve (mattype, tmp, info, rcon, sing_handler, singular_fallback,
1969 return solve (mattype, b, info, rcon,
nullptr);
1977 return solve (mattype, b, info, rcon,
nullptr);
1984 return solve (mattype, b, info, rcon,
nullptr);
1990 solve_singularity_handler sing_handler,
1994 int typ = mattype.
type ();
1997 typ = mattype.
type (*
this);
2001 retval = utsolve (mattype, b, info, rcon, sing_handler,
true, transt);
2003 retval = ltsolve (mattype, b, info, rcon, sing_handler,
true, transt);
2008 retval =
hermitian ().
solve (mattype, b, info, rcon, sing_handler,
2011 retval = fsolve (mattype, b, info, rcon, sing_handler,
true);
2013 (*current_liboctave_error_handler) (
"unknown matrix type");
2019 retval =
lssolve (b, info, rank, rcon);
2051 solve_singularity_handler sing_handler,
2063 return solve (mattype, b, info, rcon,
nullptr);
2071 return solve (mattype, b, info, rcon,
nullptr);
2078 return solve (mattype, b, info, rcon,
nullptr);
2084 solve_singularity_handler sing_handler,
2089 tmp =
solve (mattype, tmp, info, rcon, sing_handler,
true, transt);
2098 return solve (b, info, rcon,
nullptr);
2105 return solve (b, info, rcon,
nullptr);
2112 return solve (b, info, rcon,
nullptr);
2117 solve_singularity_handler sing_handler,
2121 return solve (tmp, info, rcon, sing_handler, transt);
2129 return solve (b, info, rcon,
nullptr);
2136 return solve (b, info, rcon,
nullptr);
2143 return solve (b, info, rcon,
nullptr);
2149 solve_singularity_handler sing_handler,
2153 return solve (mattype, b, info, rcon, sing_handler,
true, transt);
2181 solve_singularity_handler sing_handler,
2192 return solve (b, info, rcon,
nullptr);
2199 return solve (b, info, rcon,
nullptr);
2206 return solve (b, info, rcon,
nullptr);
2212 solve_singularity_handler sing_handler,
2216 return solve (mattype, b, info, rcon, sing_handler, transt);
2257 return lssolve (b, info, rank, rcon);
2265 return lssolve (b, info, rank, rcon);
2273 return lssolve (b, info, rank, rcon);
2290 (*current_liboctave_error_handler)
2291 (
"matrix dimension mismatch solution of linear equations");
2293 if (
m == 0 ||
n == 0 || b_nc == 0)
2305 for (
F77_INT j = 0; j < nrhs; j++)
2307 retval.
elem (i, j) = b.
elem (i, j);
2326 F77_CONST_CHAR_ARG2 (
" ", 1),
2328 F77_CHAR_ARG_LEN (6)
2329 F77_CHAR_ARG_LEN (1));
2333 F77_CONST_CHAR_ARG2 (
" ", 1),
2334 m,
n, nrhs, -1, mnthr
2335 F77_CHAR_ARG_LEN (6)
2336 F77_CHAR_ARG_LEN (1));
2341 double dminmn =
static_cast<double> (minmn);
2342 double dsmlsizp1 =
static_cast<double> (smlsiz+1);
2349 F77_INT lrwork = minmn*(10 + 2*smlsiz + 8*nlvl)
2352 n*(1+nrhs) + 2*nrhs);
2358 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2370 lwork, prwork, piwork, tmp_info));
2379 if (
n >
m &&
n >= mnthr)
2392 const F77_INT lworkaround = 4*
m +
m*
m + addend;
2395 work(0) = lworkaround;
2402 work(0) = lworkaround;
2408 double anorm = norm1 (*
this);
2425 maxmn, ps, rcon, tmp_rank,
2427 lwork, prwork, piwork, tmp_info));
2432 if (s.
elem (0) == 0.0)
2435 rcon = s.
elem (minmn - 1) / s.
elem (0);
2482 return lssolve (b, info, rank, rcon);
2491 return lssolve (b, info, rank, rcon);
2499 return lssolve (b, info, rank, rcon);
2517 (*current_liboctave_error_handler)
2518 (
"matrix dimension mismatch solution of linear equations");
2520 if (
m == 0 ||
n == 0)
2552 F77_CONST_CHAR_ARG2 (
" ", 1),
2554 F77_CHAR_ARG_LEN (6)
2555 F77_CHAR_ARG_LEN (1));
2560 double dminmn =
static_cast<double> (minmn);
2561 double dsmlsizp1 =
static_cast<double> (smlsiz+1);
2568 F77_INT lrwork = minmn*(10 + 2*smlsiz + 8*nlvl)
2569 + 3*smlsiz*nrhs + (smlsiz+1)*(smlsiz+1);
2575 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2587 lwork, prwork, piwork, tmp_info));
2599 maxmn, ps, rcon, tmp_rank,
2601 prwork, piwork, tmp_info));
2608 if (s.
elem (0) == 0.0)
2611 rcon = s.
elem (minmn - 1) / s.
elem (0);
2650 F77_XFCN (zgemm, ZGEMM, (F77_CONST_CHAR_ARG2 (
"N", 1),
2651 F77_CONST_CHAR_ARG2 (
"N", 1),
2654 F77_CHAR_ARG_LEN (1)
2655 F77_CHAR_ARG_LEN (1)));
2672 if (nr != a_nr || nc != a_nc)
2690 if (nr != a_nr || nc != a_nc)
2708 if (nr != a_nr || nc != a_nc)
2726 if (nr != a_nr || nc != a_nc)
2746 if (nr != a_nr || nc != a_nc)
2749 if (nr == 0 || nc == 0)
2767 if (nr != a_nr || nc != a_nc)
2770 if (nr == 0 || nc == 0)
2841 if (nr != 1 && nc != 1)
2842 (*current_liboctave_error_handler) (
"diag: expecting vector argument");
2900 if (nr > 0 && nc > 0)
2915 for (idx_j = 0; idx_j < nc; idx_j++)
2917 tmp_min =
elem (i, idx_j);
2921 abs_min = (real_only ? tmp_min.real ()
2922 : std::abs (tmp_min));
2934 double abs_tmp = (real_only ? tmp.real () : std::abs (tmp));
2936 if (abs_tmp < abs_min)
2946 result.
elem (i) = Complex_NaN_result;
2947 idx_arg.
elem (i) = 0;
2951 result.
elem (i) = tmp_min;
2952 idx_arg.
elem (i) = idx_j;
2975 if (nr > 0 && nc > 0)
2990 for (idx_j = 0; idx_j < nc; idx_j++)
2992 tmp_max =
elem (i, idx_j);
2996 abs_max = (real_only ? tmp_max.real ()
2997 : std::abs (tmp_max));
3009 double abs_tmp = (real_only ? tmp.real () : std::abs (tmp));
3011 if (abs_tmp > abs_max)
3021 result.
elem (i) = Complex_NaN_result;
3022 idx_arg.
elem (i) = 0;
3026 result.
elem (i) = tmp_max;
3027 idx_arg.
elem (i) = idx_j;
3050 if (nr > 0 && nc > 0)
3065 for (idx_i = 0; idx_i < nr; idx_i++)
3067 tmp_min =
elem (idx_i, j);
3071 abs_min = (real_only ? tmp_min.real ()
3072 : std::abs (tmp_min));
3084 double abs_tmp = (real_only ? tmp.real () : std::abs (tmp));
3086 if (abs_tmp < abs_min)
3096 result.
elem (j) = Complex_NaN_result;
3097 idx_arg.
elem (j) = 0;
3101 result.
elem (j) = tmp_min;
3102 idx_arg.
elem (j) = idx_i;
3125 if (nr > 0 && nc > 0)
3140 for (idx_i = 0; idx_i < nr; idx_i++)
3142 tmp_max =
elem (idx_i, j);
3146 abs_max = (real_only ? tmp_max.real ()
3147 : std::abs (tmp_max));
3159 double abs_tmp = (real_only ? tmp.real () : std::abs (tmp));
3161 if (abs_tmp > abs_max)
3171 result.
elem (j) = Complex_NaN_result;
3172 idx_arg.
elem (j) = 0;
3176 result.
elem (j) = tmp_max;
3177 idx_arg.
elem (j) = idx_i;
3195 octave::write_value<Complex> (os, a.
elem (i, j));
3208 if (nr > 0 && nc > 0)
3214 tmp = octave::read_value<Complex> (is);
3216 a.
elem (i, j) = tmp;
3257 octave::math::schur<ComplexMatrix> as (a,
"U");
3258 octave::math::schur<ComplexMatrix> bs (b,
"U");
3282 F77_XFCN (ztrsyl, ZTRSYL, (F77_CONST_CHAR_ARG2 (
"N", 1),
3283 F77_CONST_CHAR_ARG2 (
"N", 1),
3286 F77_CHAR_ARG_LEN (1)
3287 F77_CHAR_ARG_LEN (1)));
3338 get_blas_trans_arg (
bool trans,
bool conj)
3340 return trans ? (
conj ?
'C' :
'T') :
'N';
3365 if (a_nr == 0 || a_nc == 0 || b_nc == 0)
3367 else if (a.
data () == b.
data () && a_nr == b_nc && tra != trb)
3379 const char ctra = get_blas_trans_arg (tra, cja);
3382 F77_XFCN (zherk, ZHERK, (F77_CONST_CHAR_ARG2 (
"U", 1),
3383 F77_CONST_CHAR_ARG2 (&ctra, 1),
3386 F77_CHAR_ARG_LEN (1)
3387 F77_CHAR_ARG_LEN (1)));
3388 for (
F77_INT j = 0; j < a_nr; j++)
3389 for (
F77_INT i = 0; i < j; i++)
3394 F77_XFCN (zsyrk, ZSYRK, (F77_CONST_CHAR_ARG2 (
"U", 1),
3395 F77_CONST_CHAR_ARG2 (&ctra, 1),
3398 F77_CHAR_ARG_LEN (1)
3399 F77_CHAR_ARG_LEN (1)));
3400 for (
F77_INT j = 0; j < a_nr; j++)
3401 for (
F77_INT i = 0; i < j; i++)
3417 if (b_nc == 1 && a_nr == 1)
3435 else if (b_nc == 1 && ! cjb)
3437 const char ctra = get_blas_trans_arg (tra, cja);
3438 F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 (&ctra, 1),
3441 F77_CHAR_ARG_LEN (1)));
3443 else if (a_nr == 1 && ! cja && ! cjb)
3445 const char crevtrb = get_blas_trans_arg (! trb, cjb);
3446 F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 (&crevtrb, 1),
3449 F77_CHAR_ARG_LEN (1)));
3453 const char ctra = get_blas_trans_arg (tra, cja);
3454 const char ctrb = get_blas_trans_arg (trb, cjb);
3455 F77_XFCN (zgemm, ZGEMM, (F77_CONST_CHAR_ARG2 (&ctra, 1),
3456 F77_CONST_CHAR_ARG2 (&ctrb, 1),
3460 F77_CHAR_ARG_LEN (1)
3461 F77_CHAR_ARG_LEN (1)));
3471 return xgemm (a, b);
3476 #define EMPTY_RETURN_CHECK(T) \
3477 if (nr == 0 || nc == 0) \
3513 (*current_liboctave_error_handler)
3514 (
"two-arg min requires same size arguments");
3522 bool columns_are_real_only =
true;
3528 columns_are_real_only =
false;
3533 if (columns_are_real_only)
3585 (*current_liboctave_error_handler)
3586 (
"two-arg max requires same size arguments");
3594 bool columns_are_real_only =
true;
3600 columns_are_real_only =
false;
3606 if (columns_are_real_only)
3636 (*current_liboctave_error_handler)
3637 (
"linspace: vectors must be of equal length");
3647 retval.clear (
m,
n);
3649 retval.insert (
linspace (x1(i), x2(i),
n), i, 0);
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)
ComplexMatrix conj(const ComplexMatrix &a)
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)
std::istream & operator>>(std::istream &is, ComplexMatrix &a)
ComplexMatrix operator*(const ColumnVector &v, const ComplexRowVector &a)
ComplexMatrix xgemm(const ComplexMatrix &a, const ComplexMatrix &b, blas_trans_type transa, blas_trans_type transb)
base_det< Complex > ComplexDET
N Dimensional Array with copy-on-write semantics.
T & elem(octave_idx_type n)
Size of the specified dimension.
T * fortran_vec()
Size of the specified dimension.
Array< T, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
bool issquare() const
Size of the specified dimension.
octave_idx_type rows() const
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
const T * data() const
Size of the specified dimension.
octave_idx_type columns() const
octave_idx_type cols() const
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
ColumnVector extract(octave_idx_type r1, octave_idx_type r2) const
void resize(octave_idx_type n, const Complex &rfv=Complex(0))
ComplexRowVector column_max() const
ComplexMatrix & operator+=(const DiagMatrix &a)
ComplexMatrix & operator-=(const DiagMatrix &a)
ComplexMatrix lssolve(const Matrix &b) const
ComplexMatrix ifourier2d() const
ComplexColumnVector row_max() const
ComplexMatrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
ComplexColumnVector row_min() const
ComplexMatrix fourier() const
friend ComplexMatrix conj(const ComplexMatrix &a)
boolMatrix all(int dim=-1) const
ComplexMatrix & fill(double val)
ComplexMatrix append(const Matrix &a) const
ComplexMatrix diag(octave_idx_type k=0) const
ComplexMatrix pseudo_inverse(double tol=0.0) const
bool operator==(const ComplexMatrix &a) const
ComplexMatrix fourier2d() const
ComplexRowVector row(octave_idx_type i) const
ComplexMatrix & insert(const Matrix &a, octave_idx_type r, octave_idx_type c)
ComplexMatrix solve(MatrixType &mattype, const Matrix &b) const
ComplexMatrix inverse() const
bool row_is_real_only(octave_idx_type) const
ComplexMatrix sumsq(int dim=-1) const
void resize(octave_idx_type nr, octave_idx_type nc, const Complex &rfv=Complex(0))
ComplexMatrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
ComplexMatrix stack(const Matrix &a) const
ComplexMatrix cumprod(int dim=-1) const
ComplexMatrix transpose() const
ComplexMatrix prod(int dim=-1) const
ComplexDET determinant() const
ComplexMatrix cumsum(int dim=-1) const
ComplexMatrix ifourier() const
boolMatrix any(int dim=-1) const
ComplexRowVector column_min() const
bool operator!=(const ComplexMatrix &a) const
ComplexMatrix hermitian() const
bool column_is_real_only(octave_idx_type) const
ComplexMatrix sum(int dim=-1) const
ComplexColumnVector column(octave_idx_type i) const
boolNDArray any(int dim=-1) const
ComplexNDArray prod(int dim=-1) const
ComplexNDArray sumsq(int dim=-1) const
ComplexNDArray diag(octave_idx_type k=0) const
ComplexNDArray cumsum(int dim=-1) const
ComplexNDArray & insert(const NDArray &a, octave_idx_type r, octave_idx_type c)
ComplexNDArray cumprod(int dim=-1) const
boolNDArray all(int dim=-1) const
ComplexNDArray sum(int dim=-1) const
void resize(octave_idx_type n, const Complex &rfv=Complex(0))
octave_idx_type rows() const
octave_idx_type length() const
T elem(octave_idx_type r, octave_idx_type c) const
octave_idx_type cols() const
DiagMatrix inverse() const
ColumnVector extract_diag(octave_idx_type k=0) const
void mark_as_unsymmetric()
int type(bool quiet=true)
void mark_as_rectangular()
Matrix sum(int dim=-1) const
RowVector row(octave_idx_type i) const
Vector representing the dimensions (size) of an Array.
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)
octave::idx_vector idx_vector
void err_nonconformant(const char *op, octave_idx_type op1_len, octave_idx_type op2_len)
void warn_singular_matrix(double rcond)
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
Complex log2(const Complex &x)
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)
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)
std::complex< double > Complex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
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)