26#if defined (HAVE_CONFIG_H)
52#include "mx-fcm-fdm.h"
54#include "mx-fdm-fcm.h"
143 elem (i, j) =
static_cast<unsigned char> (a.
elem (i, j));
151 (*current_liboctave_error_handler) (
"complex: internal error");
170 return !(*
this == a);
201 if (r < 0 || r + a_nr >
rows () || c < 0 || c + a_nc >
cols ())
202 (*current_liboctave_error_handler) (
"range error for insert");
204 if (a_nr >0 && a_nc > 0)
222 if (r < 0 || r >=
rows () || c < 0 || c + a_len >
cols ())
223 (*current_liboctave_error_handler) (
"range error for insert");
242 if (r < 0 || r + a_len >
rows () || c < 0 || c >=
cols ())
243 (*current_liboctave_error_handler) (
"range error for insert");
263 if (r < 0 || r + a_nr >
rows () || c < 0 || c + a_nc >
cols ())
264 (*current_liboctave_error_handler) (
"range error for insert");
266 fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1);
294 if (r < 0 || r >=
rows () || c < 0 || c + a_len >
cols ())
295 (*current_liboctave_error_handler) (
"range error for insert");
309 if (r < 0 || r + a_len >
rows () || c < 0 || c >=
cols ())
310 (*current_liboctave_error_handler) (
"range error for insert");
330 if (r < 0 || r + a_nr >
rows () || c < 0 || c + a_nc >
cols ())
331 (*current_liboctave_error_handler) (
"range error for insert");
333 fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1);
354 if (nr > 0 && nc > 0)
372 if (nr > 0 && nc > 0)
391 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0
392 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc)
393 (*current_liboctave_error_handler) (
"range error for fill");
395 if (r1 > r2) { std::swap (r1, r2); }
396 if (c1 > c2) { std::swap (c1, c2); }
398 if (r2 >= r1 && c2 >= c1)
418 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0
419 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc)
420 (*current_liboctave_error_handler) (
"range error for fill");
422 if (r1 > r2) { std::swap (r1, r2); }
423 if (c1 > c2) { std::swap (c1, c2); }
425 if (r2 >= r1 && c2 >=c1)
443 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
447 retval.
insert (*
this, 0, 0);
448 retval.
insert (a, 0, nc_insert);
458 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
462 retval.
insert (*
this, 0, 0);
463 retval.
insert (a, 0, nc_insert);
472 if (nr != a.
numel ())
473 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
477 retval.
insert (*
this, 0, 0);
478 retval.
insert (a, 0, nc_insert);
488 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
492 retval.
insert (*
this, 0, 0);
493 retval.
insert (a, 0, nc_insert);
503 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
507 retval.
insert (*
this, 0, 0);
508 retval.
insert (a, 0, nc_insert);
518 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
522 retval.
insert (*
this, 0, 0);
523 retval.
insert (a, 0, nc_insert);
532 if (nr != a.
numel ())
533 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
537 retval.
insert (*
this, 0, 0);
538 retval.
insert (a, 0, nc_insert);
548 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
552 retval.
insert (*
this, 0, 0);
553 retval.
insert (a, 0, nc_insert);
563 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
567 retval.
insert (*
this, 0, 0);
568 retval.
insert (a, nr_insert, 0);
577 if (nc != a.
numel ())
578 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
582 retval.
insert (*
this, 0, 0);
583 retval.
insert (a, nr_insert, 0);
593 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
597 retval.
insert (*
this, 0, 0);
598 retval.
insert (a, nr_insert, 0);
608 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
612 retval.
insert (*
this, 0, 0);
613 retval.
insert (a, nr_insert, 0);
623 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
627 retval.
insert (*
this, 0, 0);
628 retval.
insert (a, nr_insert, 0);
637 if (nc != a.
numel ())
638 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
642 retval.
insert (*
this, 0, 0);
643 retval.
insert (a, nr_insert, 0);
653 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
657 retval.
insert (*
this, 0, 0);
658 retval.
insert (a, nr_insert, 0);
668 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
672 retval.
insert (*
this, 0, 0);
673 retval.
insert (a, nr_insert, 0);
680 return do_mx_unary_map<FloatComplex, FloatComplex, std::conj<float>> (a);
689 if (r1 > r2) { std::swap (r1, r2); }
690 if (c1 > c2) { std::swap (c1, c2); }
726 float sum = colsum.
xelem (i);
745 return inverse (mattype, info, rcon, 0, 0);
753 return inverse (mattype, info, rcon, 0, 0);
758 bool calc_cond)
const
761 return inverse (mattype, info, rcon, force, calc_cond);
769 return inverse (mattype, info, rcon, 0, 0);
776 return inverse (mattype, info, rcon, 0, 0);
781 float& rcon,
bool force,
bool calc_cond)
const
788 if (nr != nc || nr == 0 || nc == 0)
789 (*current_liboctave_error_handler) (
"inverse requires square matrix");
791 int typ = mattype.
type ();
799 F77_XFCN (ctrtri, CTRTRI, (F77_CONST_CHAR_ARG2 (&uplo, 1),
800 F77_CONST_CHAR_ARG2 (&udiag, 1),
803 F77_CHAR_ARG_LEN (1)));
819 F77_XFCN (ctrcon, CTRCON, (F77_CONST_CHAR_ARG2 (&job, 1),
820 F77_CONST_CHAR_ARG2 (&uplo, 1),
821 F77_CONST_CHAR_ARG2 (&udiag, 1),
826 F77_CHAR_ARG_LEN (1)));
828 if (ztrcon_info != 0)
832 if (info == -1 && ! force)
840 float& rcon,
bool force,
bool calc_cond)
const
848 (*current_liboctave_error_handler) (
"inverse requires square matrix");
851 F77_INT *pipvt = ipvt.fortran_vec ();
868 lwork = (lwork < 2 * nc ? 2 * nc : lwork);
876 float anorm =
norm1 (retval);
902 F77_XFCN (cgecon, CGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
905 F77_CHAR_ARG_LEN (1)));
907 if (cgecon_info != 0)
911 if ((info == -1 && ! force)
921 if (zgetri_info != 0)
933 float& rcon,
bool force,
bool calc_cond)
const
935 int typ = mattype.
type (
false);
939 typ = mattype.
type (*
this);
966 ret =
tinverse (mattype, info, rcon, force, calc_cond);
975 rcon =
chol.rcond ();
978 ret =
chol.inverse ();
985 ret =
finverse (mattype, info, rcon, force, calc_cond);
987 if ((calc_cond || mattype.
ishermitian ()) && rcon == 0.0)
1018 * std::numeric_limits<float>::epsilon ();
1024 while (r >= 0 && sigma.
elem (r) < tol)
1040#if defined (HAVE_FFTW)
1045 std::size_t nr =
rows ();
1046 std::size_t nc =
cols ();
1050 std::size_t npts, nsamples;
1052 if (nr == 1 || nc == 1)
1054 npts = (nr > nc ? nr : nc);
1074 std::size_t nr =
rows ();
1075 std::size_t nc =
cols ();
1079 std::size_t npts, nsamples;
1081 if (nr == 1 || nc == 1)
1083 npts = (nr > nc ? nr : nc);
1133 (*current_liboctave_error_handler)
1134 (
"support for FFTW was unavailable or disabled when liboctave was built");
1142 (*current_liboctave_error_handler)
1143 (
"support for FFTW was unavailable or disabled when liboctave was built");
1151 (*current_liboctave_error_handler)
1152 (
"support for FFTW was unavailable or disabled when liboctave was built");
1160 (*current_liboctave_error_handler)
1161 (
"support for FFTW was unavailable or disabled when liboctave was built");
1185 bool calc_cond)
const
1188 return determinant (mattype, info, rcon, calc_cond);
1194 bool calc_cond)
const
1205 (*current_liboctave_error_handler) (
"matrix must be square");
1207 volatile int typ = mattype.
type ();
1214 typ = mattype.
type (*
this);
1220 for (
F77_INT i = 0; i < nc; i++)
1221 retval *=
elem (i, i);
1230 anorm =
norm1 (*
this);
1235 F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1237 F77_CHAR_ARG_LEN (1)));
1256 F77_XFCN (cpocon, CPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1259 F77_CHAR_ARG_LEN (1)));
1267 for (
F77_INT i = 0; i < nc; i++)
1268 retval *= atmp(i, i);
1270 retval = retval.
square ();
1274 (*current_liboctave_error_handler) (
"det: invalid dense matrix type");
1287 float anorm =
norm1 (*
this);
1320 F77_XFCN (cgecon, CGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1323 F77_CHAR_ARG_LEN (1)));
1335 for (
F77_INT i = 0; i < nc; i++)
1338 retval *= (ipvt(i) != (i+1)) ? -c : c;
1351 return rcond (mattype);
1362 (*current_liboctave_error_handler) (
"matrix must be square");
1364 if (nr == 0 || nc == 0)
1368 volatile int typ = mattype.
type ();
1371 typ = mattype.
type (*
this);
1387 F77_XFCN (ctrcon, CTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1388 F77_CONST_CHAR_ARG2 (&uplo, 1),
1389 F77_CONST_CHAR_ARG2 (&dia, 1),
1392 F77_CHAR_ARG_LEN (1)
1393 F77_CHAR_ARG_LEN (1)
1394 F77_CHAR_ARG_LEN (1)));
1400 (*current_liboctave_error_handler)
1401 (
"permuted triangular matrix not implemented");
1415 F77_XFCN (ctrcon, CTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1416 F77_CONST_CHAR_ARG2 (&uplo, 1),
1417 F77_CONST_CHAR_ARG2 (&dia, 1),
1420 F77_CHAR_ARG_LEN (1)
1421 F77_CHAR_ARG_LEN (1)
1422 F77_CHAR_ARG_LEN (1)));
1428 (*current_liboctave_error_handler)
1429 (
"permuted triangular matrix not implemented");
1442 anorm =
norm1 (atmp);
1444 F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1446 F77_CHAR_ARG_LEN (1)));
1462 F77_XFCN (cpocon, CPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1465 F77_CHAR_ARG_LEN (1)));
1483 anorm =
norm1 (atmp);
1505 F77_XFCN (cgecon, CGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1508 F77_CHAR_ARG_LEN (1)));
1525 solve_singularity_handler sing_handler,
1537 (*current_liboctave_error_handler)
1538 (
"matrix dimension mismatch solution of linear equations");
1540 if (nr == 0 || nc == 0 || b_nc == 0)
1544 volatile int typ = mattype.
type ();
1552 (*current_liboctave_error_handler)
1553 (
"permuted triangular matrix not implemented");
1567 F77_XFCN (ctrtrs, CTRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1568 F77_CONST_CHAR_ARG2 (&trans, 1),
1569 F77_CONST_CHAR_ARG2 (&dia, 1),
1572 F77_CHAR_ARG_LEN (1)
1573 F77_CHAR_ARG_LEN (1)
1574 F77_CHAR_ARG_LEN (1)));
1589 F77_XFCN (ctrcon, CTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1590 F77_CONST_CHAR_ARG2 (&uplo, 1),
1591 F77_CONST_CHAR_ARG2 (&dia, 1),
1594 F77_CHAR_ARG_LEN (1)
1595 F77_CHAR_ARG_LEN (1)
1596 F77_CHAR_ARG_LEN (1)));
1603 volatile float rcond_plus_one = rcon + 1.0;
1610 sing_handler (rcon);
1627 solve_singularity_handler sing_handler,
1639 (*current_liboctave_error_handler)
1640 (
"matrix dimension mismatch solution of linear equations");
1642 if (nr == 0 || nc == 0 || b_nc == 0)
1646 volatile int typ = mattype.
type ();
1654 (*current_liboctave_error_handler)
1655 (
"permuted triangular matrix not implemented");
1669 F77_XFCN (ctrtrs, CTRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1670 F77_CONST_CHAR_ARG2 (&trans, 1),
1671 F77_CONST_CHAR_ARG2 (&dia, 1),
1674 F77_CHAR_ARG_LEN (1)
1675 F77_CHAR_ARG_LEN (1)
1676 F77_CHAR_ARG_LEN (1)));
1691 F77_XFCN (ctrcon, CTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1692 F77_CONST_CHAR_ARG2 (&uplo, 1),
1693 F77_CONST_CHAR_ARG2 (&dia, 1),
1696 F77_CHAR_ARG_LEN (1)
1697 F77_CHAR_ARG_LEN (1)
1698 F77_CHAR_ARG_LEN (1)));
1705 volatile float rcond_plus_one = rcon + 1.0;
1712 sing_handler (rcon);
1729 solve_singularity_handler sing_handler,
1730 bool calc_cond)
const
1740 if (nr != nc || nr != b_nr)
1741 (*current_liboctave_error_handler)
1742 (
"matrix dimension mismatch solution of linear equations");
1744 if (nr == 0 || b_nc == 0)
1748 volatile int typ = mattype.
type ();
1763 anorm =
norm1 (atmp);
1767 F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1769 F77_CHAR_ARG_LEN (1)));
1791 F77_XFCN (cpocon, CPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1794 F77_CHAR_ARG_LEN (1)));
1801 volatile float rcond_plus_one = rcon + 1.0;
1808 sing_handler (rcon);
1819 F77_XFCN (cpotrs, CPOTRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1822 F77_CHAR_ARG_LEN (1)));
1850 if (calc_cond && anorm < 0.0)
1851 anorm =
norm1 (atmp);
1862 nr, pipvt, tmp_info));
1874 sing_handler (rcon);
1886 F77_XFCN (cgecon, CGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1889 F77_CHAR_ARG_LEN (1)));
1896 volatile float rcond_plus_one = rcon + 1.0;
1901 sing_handler (rcon);
1913 F77_XFCN (cgetrs, CGETRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1916 F77_CHAR_ARG_LEN (1)));
1941 return solve (mattype, b, info, rcon,
nullptr);
1949 return solve (mattype, b, info, rcon,
nullptr);
1956 return solve (mattype, b, info, rcon,
nullptr);
1962 solve_singularity_handler sing_handler,
1966 return solve (mattype, tmp, info, rcon, sing_handler, singular_fallback,
1976 return solve (mattype, b, info, rcon,
nullptr);
1984 return solve (mattype, b, info, rcon,
nullptr);
1991 return solve (mattype, b, info, rcon,
nullptr);
1997 solve_singularity_handler sing_handler,
1998 bool singular_fallback,
2002 int typ = mattype.
type ();
2005 typ = mattype.
type (*
this);
2009 retval =
utsolve (mattype, b, info, rcon, sing_handler,
true, transt);
2012 retval =
ltsolve (mattype, b, info, rcon, sing_handler,
true, transt);
2017 retval =
hermitian ().
solve (mattype, b, info, rcon, sing_handler,
2020 retval =
fsolve (mattype, b, info, rcon, sing_handler,
true);
2022 (*current_liboctave_error_handler) (
"unknown matrix type");
2028 retval =
lssolve (b, info, rank, rcon);
2061 solve_singularity_handler sing_handler,
2065 sing_handler, transt);
2074 return solve (mattype, b, info, rcon,
nullptr);
2083 return solve (mattype, b, info, rcon,
nullptr);
2091 return solve (mattype, b, info, rcon,
nullptr);
2098 solve_singularity_handler sing_handler,
2103 tmp =
solve (mattype, tmp, info, rcon, sing_handler,
true, transt);
2112 return solve (b, info, rcon,
nullptr);
2119 return solve (b, info, rcon,
nullptr);
2126 return solve (b, info, rcon,
nullptr);
2132 solve_singularity_handler sing_handler,
2136 return solve (tmp, info, rcon, sing_handler, transt);
2144 return solve (b, info, rcon,
nullptr);
2152 return solve (b, info, rcon,
nullptr);
2159 return solve (b, info, rcon,
nullptr);
2165 solve_singularity_handler sing_handler,
2169 return solve (mattype, b, info, rcon, sing_handler,
true, transt);
2198 solve_singularity_handler sing_handler,
2209 return solve (b, info, rcon,
nullptr);
2217 return solve (b, info, rcon,
nullptr);
2225 return solve (b, info, rcon,
nullptr);
2232 solve_singularity_handler sing_handler,
2236 return solve (mattype, b, info, rcon, sing_handler, transt);
2277 return lssolve (b, info, rank, rcon);
2286 return lssolve (b, info, rank, rcon);
2294 return lssolve (b, info, rank, rcon);
2311 (*current_liboctave_error_handler)
2312 (
"matrix dimension mismatch solution of linear equations");
2314 if (m == 0 || n == 0 || b_nc == 0)
2318 volatile F77_INT minmn = (m < n ? m : n);
2319 F77_INT maxmn = (m > n ? m : n);
2326 for (
F77_INT j = 0; j < nrhs; j++)
2327 for (
F77_INT i = 0; i < m; i++)
2328 retval.
elem (i, j) = b.
elem (i, j);
2347 F77_CONST_CHAR_ARG2 (
" ", 1),
2349 F77_CHAR_ARG_LEN (6)
2350 F77_CHAR_ARG_LEN (1));
2354 F77_CONST_CHAR_ARG2 (
" ", 1),
2355 m, n, nrhs, -1, mnthr
2356 F77_CHAR_ARG_LEN (6)
2357 F77_CHAR_ARG_LEN (1));
2362 float dminmn =
static_cast<float> (minmn);
2363 float dsmlsizp1 =
static_cast<float> (smlsiz+1);
2370 F77_INT lrwork = minmn*(10 + 2*smlsiz + 8*nlvl)
2373 n*(1+nrhs) + 2*nrhs);
2379 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2391 lwork, prwork, piwork, tmp_info));
2400 if (n > m && n >= mnthr)
2413 const F77_INT lworkaround = 4*m + m*m + addend;
2416 work(0) = lworkaround;
2420 F77_INT lworkaround = 2*m + m*nrhs;
2423 work(0) = lworkaround;
2429 float anorm =
norm1 (*
this);
2446 maxmn, ps, rcon, tmp_rank,
2448 lwork, prwork, piwork, tmp_info));
2453 if (s.
elem (0) == 0.0)
2456 rcon = s.
elem (minmn - 1) / s.
elem (0);
2504 return lssolve (b, info, rank, rcon);
2513 return lssolve (b, info, rank, rcon);
2522 return lssolve (b, info, rank, rcon);
2541 (*current_liboctave_error_handler)
2542 (
"matrix dimension mismatch solution of linear equations");
2544 if (m == 0 || n == 0)
2548 volatile F77_INT minmn = (m < n ? m : n);
2549 F77_INT maxmn = (m > n ? m : n);
2556 for (
F77_INT i = 0; i < m; i++)
2576 F77_CONST_CHAR_ARG2 (
" ", 1),
2578 F77_CHAR_ARG_LEN (6)
2579 F77_CHAR_ARG_LEN (1));
2584 float dminmn =
static_cast<float> (minmn);
2585 float dsmlsizp1 =
static_cast<float> (smlsiz+1);
2592 F77_INT lrwork = minmn*(10 + 2*smlsiz + 8*nlvl)
2593 + 3*smlsiz*nrhs + (smlsiz+1)*(smlsiz+1);
2599 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2611 lwork, prwork, piwork, tmp_info));
2623 maxmn, ps, rcon, tmp_rank,
2625 prwork, piwork, tmp_info));
2632 if (s.
elem (0) == 0.0)
2635 rcon = s.
elem (minmn - 1) / s.
elem (0);
2674 F77_XFCN (cgemm, CGEMM, (F77_CONST_CHAR_ARG2 (
"N", 1),
2675 F77_CONST_CHAR_ARG2 (
"N", 1),
2678 F77_CHAR_ARG_LEN (1)
2679 F77_CHAR_ARG_LEN (1)));
2696 if (nr != a_nr || nc != a_nc)
2714 if (nr != a_nr || nc != a_nc)
2732 if (nr != a_nr || nc != a_nc)
2750 if (nr != a_nr || nc != a_nc)
2770 if (nr != a_nr || nc != a_nc)
2773 if (nr == 0 || nc == 0)
2791 if (nr != a_nr || nc != a_nc)
2794 if (nr == 0 || nc == 0)
2866 if (nr == 1 || nc == 1)
2927 if (nr > 0 && nc > 0)
2942 for (idx_j = 0; idx_j < nc; idx_j++)
2944 tmp_min =
elem (i, idx_j);
2948 abs_min = (real_only ? tmp_min.real ()
2961 float abs_tmp = (real_only ? tmp.real () :
std::abs (tmp));
2963 if (abs_tmp < abs_min)
2974 idx_arg.
elem (i) = 0;
2978 result.
elem (i) = tmp_min;
2979 idx_arg.
elem (i) = idx_j;
3002 if (nr > 0 && nc > 0)
3017 for (idx_j = 0; idx_j < nc; idx_j++)
3019 tmp_max =
elem (i, idx_j);
3023 abs_max = (real_only ? tmp_max.real ()
3036 float abs_tmp = (real_only ? tmp.real () :
std::abs (tmp));
3038 if (abs_tmp > abs_max)
3049 idx_arg.
elem (i) = 0;
3053 result.
elem (i) = tmp_max;
3054 idx_arg.
elem (i) = idx_j;
3077 if (nr > 0 && nc > 0)
3092 for (idx_i = 0; idx_i < nr; idx_i++)
3094 tmp_min =
elem (idx_i, j);
3098 abs_min = (real_only ? tmp_min.real ()
3111 float abs_tmp = (real_only ? tmp.real () :
std::abs (tmp));
3113 if (abs_tmp < abs_min)
3124 idx_arg.
elem (j) = 0;
3128 result.
elem (j) = tmp_min;
3129 idx_arg.
elem (j) = idx_i;
3152 if (nr > 0 && nc > 0)
3167 for (idx_i = 0; idx_i < nr; idx_i++)
3169 tmp_max =
elem (idx_i, j);
3173 abs_max = (real_only ? tmp_max.real ()
3186 float abs_tmp = (real_only ? tmp.real () :
std::abs (tmp));
3188 if (abs_tmp > abs_max)
3199 idx_arg.
elem (j) = 0;
3203 result.
elem (j) = tmp_max;
3204 idx_arg.
elem (j) = idx_i;
3222 octave::write_value<Complex> (os, a.
elem (i, j));
3235 if (nr > 0 && nc > 0)
3241 tmp = octave::read_value<FloatComplex> (is);
3243 a.
elem (i, j) = tmp;
3308 F77_XFCN (ctrsyl, CTRSYL, (F77_CONST_CHAR_ARG2 (
"N", 1),
3309 F77_CONST_CHAR_ARG2 (
"N", 1),
3312 F77_CHAR_ARG_LEN (1)
3313 F77_CHAR_ARG_LEN (1)));
3366 return trans ? (
conj ?
'C' :
'T') :
'N';
3391 if (a_nr == 0 || a_nc == 0 || b_nc == 0)
3393 else if (a.
data () == b.
data () && a_nr == b_nc && tra != trb)
3408 F77_XFCN (cherk, CHERK, (F77_CONST_CHAR_ARG2 (
"U", 1),
3409 F77_CONST_CHAR_ARG2 (&ctra, 1),
3412 F77_CHAR_ARG_LEN (1)
3413 F77_CHAR_ARG_LEN (1)));
3414 for (
F77_INT j = 0; j < a_nr; j++)
3415 for (
F77_INT i = 0; i < j; i++)
3420 F77_XFCN (csyrk, CSYRK, (F77_CONST_CHAR_ARG2 (
"U", 1),
3421 F77_CONST_CHAR_ARG2 (&ctra, 1),
3424 F77_CHAR_ARG_LEN (1)
3425 F77_CHAR_ARG_LEN (1)));
3426 for (
F77_INT j = 0; j < a_nr; j++)
3427 for (
F77_INT i = 0; i < j; i++)
3443 if (b_nc == 1 && a_nr == 1)
3461 else if (b_nc == 1 && ! cjb)
3464 F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (&ctra, 1),
3467 F77_CHAR_ARG_LEN (1)));
3469 else if (a_nr == 1 && ! cja && ! cjb)
3472 F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (&crevtrb, 1),
3475 F77_CHAR_ARG_LEN (1)));
3481 F77_XFCN (cgemm, CGEMM, (F77_CONST_CHAR_ARG2 (&ctra, 1),
3482 F77_CONST_CHAR_ARG2 (&ctrb, 1),
3485 F77_CHAR_ARG_LEN (1)
3486 F77_CHAR_ARG_LEN (1)));
3496 return xgemm (a, b);
3502#define EMPTY_RETURN_CHECK(T) \
3503 if (nr == 0 || nc == 0) \
3539 (*current_liboctave_error_handler)
3540 (
"two-arg min requires same size arguments");
3548 bool columns_are_real_only =
true;
3554 columns_are_real_only =
false;
3559 if (columns_are_real_only)
3611 (*current_liboctave_error_handler)
3612 (
"two-arg max requires same size arguments");
3620 bool columns_are_real_only =
true;
3626 columns_are_real_only =
false;
3631 if (columns_are_real_only)
3660 if (x2.
numel () != m)
3661 (*current_liboctave_error_handler)
3662 (
"linspace: vectors must be of equal length");
3668 retval.
clear (m, 0);
3672 retval.clear (m, n);
3674 retval.xelem (i, 0) = x1(i);
3679 delta[i] = (x1(i) == x2(i)) ? 0 : (x2(i) - x1(i)) / (n - 1.0f);
3683 retval.xelem (i, j) = x1(i) +
static_cast<float> (j)*delta[i];
3686 retval.
xelem (i, n-1) = x2(i);
base_det< FloatComplex > FloatComplexDET
N Dimensional Array with copy-on-write semantics.
bool issquare(void) const
FloatComplex & xelem(octave_idx_type n)
OCTARRAY_API void clear(void)
OCTARRAY_API Array< FloatComplex, 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
FloatComplex & 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.
OCTARRAY_API Array< T, Alloc > & insert(const Array< T, Alloc > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
octave_idx_type columns(void) const
const FloatComplex * data(void) const
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
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
OCTAVE_API FloatColumnVector extract(octave_idx_type r1, octave_idx_type r2) const
void resize(octave_idx_type n, const FloatComplex &rfv=FloatComplex(0))
OCTAVE_API bool ishermitian(void) const
OCTAVE_API bool row_is_real_only(octave_idx_type) const
OCTAVE_API boolMatrix all(int dim=-1) const
OCTAVE_API FloatComplexMatrix sumsq(int dim=-1) const
OCTAVE_API FloatComplexMatrix pseudo_inverse(float tol=0.0) const
OCTAVE_API FloatComplexMatrix fourier2d(void) const
FloatComplexMatrix(void)=default
OCTAVE_API FloatComplexMatrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
FloatComplexMatrix utsolve(MatrixType &mattype, const FloatComplexMatrix &b, octave_idx_type &info, float &rcon, solve_singularity_handler sing_handler, bool calc_cond=false, blas_trans_type transt=blas_no_trans) const
FloatComplexMatrix hermitian(void) const
OCTAVE_API FloatComplexMatrix lssolve(const FloatMatrix &b) const
OCTAVE_API FloatMatrix abs(void) const
OCTAVE_API FloatComplexMatrix & operator+=(const FloatDiagMatrix &a)
OCTAVE_API FloatComplexRowVector row(octave_idx_type i) const
OCTAVE_API bool operator!=(const FloatComplexMatrix &a) const
OCTAVE_API FloatComplexMatrix fourier(void) const
OCTAVE_API FloatComplexColumnVector column(octave_idx_type i) const
OCTAVE_API FloatComplexMatrix ifourier2d(void) const
OCTAVE_API FloatComplexDET determinant(void) const
FloatComplexMatrix transpose(void) const
OCTAVE_API FloatComplexMatrix stack(const FloatMatrix &a) const
OCTAVE_API FloatComplexMatrix cumsum(int dim=-1) const
OCTAVE_API FloatComplexMatrix & insert(const FloatMatrix &a, octave_idx_type r, octave_idx_type c)
OCTAVE_API bool operator==(const FloatComplexMatrix &a) const
OCTAVE_API FloatComplexMatrix diag(octave_idx_type k=0) const
void resize(octave_idx_type nr, octave_idx_type nc, const FloatComplex &rfv=FloatComplex(0))
OCTAVE_API FloatComplexMatrix sum(int dim=-1) const
OCTAVE_API FloatComplexRowVector column_min(void) const
OCTAVE_API FloatComplexMatrix ifourier(void) const
OCTAVE_API FloatComplexColumnVector row_max(void) const
OCTAVE_API FloatComplexMatrix solve(MatrixType &mattype, const FloatMatrix &b) const
OCTAVE_API FloatComplexMatrix & operator-=(const FloatDiagMatrix &a)
OCTAVE_API boolMatrix any(int dim=-1) const
OCTAVE_API FloatComplexMatrix & fill(float val)
OCTAVE_API FloatComplexMatrix inverse(void) const
OCTAVE_API bool column_is_real_only(octave_idx_type) const
OCTAVE_API FloatComplexRowVector column_max(void) const
OCTAVE_API FloatComplexColumnVector row_min(void) const
OCTAVE_API FloatComplexMatrix append(const FloatMatrix &a) const
FloatComplexMatrix tinverse(MatrixType &mattype, octave_idx_type &info, float &rcon, bool force, bool calc_cond) const
FloatComplexMatrix ltsolve(MatrixType &mattype, const FloatComplexMatrix &b, octave_idx_type &info, float &rcon, solve_singularity_handler sing_handler, bool calc_cond=false, blas_trans_type transt=blas_no_trans) const
OCTAVE_API FloatComplexMatrix cumprod(int dim=-1) const
friend OCTAVE_API FloatComplexMatrix conj(const FloatComplexMatrix &a)
OCTAVE_API float rcond(void) const
OCTAVE_API FloatComplexMatrix prod(int dim=-1) const
FloatComplexMatrix fsolve(MatrixType &mattype, const FloatComplexMatrix &b, octave_idx_type &info, float &rcon, solve_singularity_handler sing_handler, bool calc_cond=false) const
OCTAVE_API FloatComplexMatrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
FloatComplexMatrix finverse(MatrixType &mattype, octave_idx_type &info, float &rcon, bool force, bool calc_cond) const
OCTAVE_API FloatNDArray abs(void) const
OCTAVE_API FloatComplexNDArray sum(int dim=-1) const
OCTAVE_API FloatComplexNDArray cumprod(int dim=-1) const
OCTAVE_API FloatComplexNDArray sumsq(int dim=-1) const
OCTAVE_API FloatComplexNDArray prod(int dim=-1) const
OCTAVE_API FloatComplexNDArray cumsum(int dim=-1) const
OCTAVE_API boolNDArray all(int dim=-1) const
OCTAVE_API boolNDArray any(int dim=-1) const
OCTAVE_API FloatComplexNDArray diag(octave_idx_type k=0) const
void resize(octave_idx_type n, const FloatComplex &rfv=FloatComplex(0))
FloatColumnVector extract_diag(octave_idx_type k=0) const
OCTAVE_API FloatMatrix sum(int dim=-1) const
OCTAVE_API FloatRowVector row(octave_idx_type i) const
bool ishermitian(void) const
void mark_as_rectangular(void)
OCTAVE_API void mark_as_unsymmetric(void)
OCTAVE_API int type(bool quiet=true)
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_CONST_CMPLX_ARG(x)
#define F77_XFCN(f, F, args)
octave_f77_int_type F77_INT
FloatComplexMatrix Sylvester(const FloatComplexMatrix &a, const FloatComplexMatrix &b, const FloatComplexMatrix &c)
FloatComplexMatrix xgemm(const FloatComplexMatrix &a, const FloatComplexMatrix &b, blas_trans_type transa, blas_trans_type transb)
FloatComplexMatrix operator*(const FloatColumnVector &v, const FloatComplexRowVector &a)
FloatComplexMatrix max(const FloatComplex &c, const FloatComplexMatrix &m)
static char get_blas_trans_arg(bool trans, bool conj)
std::ostream & operator<<(std::ostream &os, const FloatComplexMatrix &a)
static const FloatComplex FloatComplex_NaN_result(octave::numeric_limits< float >::NaN(), octave::numeric_limits< float >::NaN())
static float norm1(const FloatComplexMatrix &a)
FloatComplexMatrix linspace(const FloatComplexColumnVector &x1, const FloatComplexColumnVector &x2, octave_idx_type n)
#define EMPTY_RETURN_CHECK(T)
FloatComplexMatrix min(const FloatComplex &c, const FloatComplexMatrix &m)
FloatComplexMatrix conj(const FloatComplexMatrix &a)
FloatComplexMatrix Givens(const FloatComplex &x, const FloatComplex &y)
std::istream & operator>>(std::istream &is, FloatComplexMatrix &a)
double norm(const ColumnVector &v)
void scale(Matrix &m, double x, double y, double z)
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
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 FloatDiagMatrix
class OCTAVE_API FloatComplexMatrix
class OCTAVE_API FloatComplexColumnVector
class OCTAVE_API FloatComplexDiagMatrix
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< float > FloatComplex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
static bool scalar(const dim_vector &dims)
subroutine xcdotc(n, zx, incx, zy, incy, retval)
subroutine xcdotu(n, zx, incx, zy, incy, retval)
F77_RET_T F77_FUNC(xerbla, XERBLA)(F77_CONST_CHAR_ARG_DEF(s_arg
subroutine xilaenv(ispec, name, opts, n1, n2, n3, n4, retval)