26 #if defined (HAVE_CONFIG_H)
103 elem (ia(i), i) = 1.0;
117 elem (i, j) =
static_cast<unsigned char> (a.
elem (i, j));
132 return !(*
this == a);
163 if (r < 0 || r >=
rows () || c < 0 || c + a_len >
cols ())
164 (*current_liboctave_error_handler) (
"range error for insert");
182 if (r < 0 || r + a_len >
rows () || c < 0 || c >=
cols ())
183 (*current_liboctave_error_handler) (
"range error for insert");
202 if (r < 0 || r + a_nr >
rows () || c < 0 || c + a_nc >
cols ())
203 (*current_liboctave_error_handler) (
"range error for insert");
205 fill (0.0,
r, c,
r + a_nr - 1, c + a_nc - 1);
226 if (nr > 0 && nc > 0)
245 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0
246 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc)
247 (*current_liboctave_error_handler) (
"range error for fill");
249 if (r1 > r2) { std::swap (r1, r2); }
250 if (c1 > c2) { std::swap (c1, c2); }
252 if (r2 >= r1 && c2 >= c1)
270 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
274 retval.
insert (*
this, 0, 0);
275 retval.
insert (a, 0, nc_insert);
285 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
289 retval.
insert (*
this, 0, 0);
290 retval.
insert (a, 0, nc_insert);
299 if (nr != a.
numel ())
300 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
303 Matrix retval (nr, nc + 1);
304 retval.
insert (*
this, 0, 0);
305 retval.
insert (a, 0, nc_insert);
315 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
319 retval.
insert (*
this, 0, 0);
320 retval.
insert (a, 0, nc_insert);
330 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
334 retval.
insert (*
this, 0, 0);
335 retval.
insert (a, nr_insert, 0);
344 if (nc != a.
numel ())
345 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
348 Matrix retval (nr + 1, nc);
349 retval.
insert (*
this, 0, 0);
350 retval.
insert (a, nr_insert, 0);
360 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
364 retval.
insert (*
this, 0, 0);
365 retval.
insert (a, nr_insert, 0);
375 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
379 retval.
insert (*
this, 0, 0);
380 retval.
insert (a, nr_insert, 0);
400 if (r1 > r2) { std::swap (r1, r2); }
401 if (c1 > c2) { std::swap (c1, c2); }
437 double sum = colsum.
xelem (i);
456 return inverse (mattype, info, rcon, 0, 0);
464 return inverse (mattype, info, rcon, 0, 0);
469 bool calc_cond)
const
472 return inverse (mattype, info, rcon, force, calc_cond);
480 return inverse (mattype, info, rcon, 0, 0);
487 return inverse (mattype, info, rcon, 0, 0);
492 bool force,
bool calc_cond)
const
499 if (nr != nc || nr == 0 || nc == 0)
500 (*current_liboctave_error_handler) (
"inverse requires square matrix");
502 int typ = mattype.
type ();
510 F77_XFCN (dtrtri, DTRTRI, (F77_CONST_CHAR_ARG2 (&uplo, 1),
511 F77_CONST_CHAR_ARG2 (&udiag, 1),
512 nr, tmp_data, nr, tmp_info
514 F77_CHAR_ARG_LEN (1)));
530 F77_XFCN (dtrcon, DTRCON, (F77_CONST_CHAR_ARG2 (&job, 1),
531 F77_CONST_CHAR_ARG2 (&uplo, 1),
532 F77_CONST_CHAR_ARG2 (&udiag, 1),
533 nr, tmp_data, nr, rcon,
534 work, iwork, dtrcon_info
537 F77_CHAR_ARG_LEN (1)));
539 if (dtrcon_info != 0)
543 if (info == -1 && ! force)
551 bool force,
bool calc_cond)
const
558 if (nr != nc || nr == 0 || nc == 0)
559 (*current_liboctave_error_handler) (
"inverse requires square matrix");
562 F77_INT *pipvt = ipvt.fortran_vec ();
573 F77_XFCN (dgetri, DGETRI, (nc, tmp_data, nr, pipvt,
574 z.fortran_vec (), lwork, tmp_info));
576 lwork =
static_cast<F77_INT> (z(0));
577 lwork = (lwork < 4 * nc ? 4 * nc : lwork);
579 double *pz = z.fortran_vec ();
587 anorm = norm1 (retval);
589 F77_XFCN (dgetrf, DGETRF, (nc, nc, tmp_data, nr, pipvt, tmp_info));
608 F77_INT *piz = iz.fortran_vec ();
609 F77_XFCN (dgecon, DGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
610 nc, tmp_data, nr, anorm,
611 rcon, pz, piz, dgecon_info
612 F77_CHAR_ARG_LEN (1)));
614 if (dgecon_info != 0)
619 if (info == -1 && ! force)
625 F77_XFCN (dgetri, DGETRI, (nc, tmp_data, nr, pipvt,
626 pz, lwork, dgetri_info));
628 if (dgetri_info != 0)
640 bool force,
bool calc_cond)
const
642 int typ = mattype.
type (
false);
646 typ = mattype.
type (*
this);
653 double scalar = this->
elem (0);
663 ret = tinverse (mattype, info, rcon, force, calc_cond);
668 octave::math::chol<Matrix>
chol (*
this, info,
true, calc_cond);
682 ret = finverse (mattype, info, rcon, force, calc_cond);
684 if ((calc_cond || mattype.
ishermitian ()) && rcon == 0.0)
695 octave::math::svd<Matrix> result (*
this,
696 octave::math::svd<Matrix>::Type::economy);
699 Matrix U = result.left_singular_matrix ();
700 Matrix V = result.right_singular_matrix ();
711 * std::numeric_limits<double>::epsilon ();
717 while (
r >= 0 && sigma.
elem (
r) < tol)
721 return Matrix (nc, nr, 0.0);
726 Matrix Vr =
V.extract (0, 0, nc-1,
r);
731 #if defined (HAVE_FFTW)
736 std::size_t nr =
rows ();
737 std::size_t nc =
cols ();
741 std::size_t npts, nsamples;
743 if (nr == 1 || nc == 1)
745 npts = (nr > nc ? nr : nc);
754 const double *in (
data ());
757 octave::fftw::fft (in, out, npts, nsamples);
765 std::size_t nr =
rows ();
766 std::size_t nc =
cols ();
770 std::size_t npts, nsamples;
772 if (nr == 1 || nc == 1)
774 npts = (nr > nc ? nr : nc);
787 octave::fftw::ifft (in, out, npts, nsamples);
797 const double *in =
data ();
799 octave::fftw::fftNd (in, retval.
fortran_vec (), 2, dv);
812 octave::fftw::ifftNd (out, out, 2, dv);
822 (*current_liboctave_error_handler)
823 (
"support for FFTW was unavailable or disabled when liboctave was built");
831 (*current_liboctave_error_handler)
832 (
"support for FFTW was unavailable or disabled when liboctave was built");
840 (*current_liboctave_error_handler)
841 (
"support for FFTW was unavailable or disabled when liboctave was built");
849 (*current_liboctave_error_handler)
850 (
"support for FFTW was unavailable or disabled when liboctave was built");
876 return determinant (mattype, info, rcon, calc_cond);
892 (*current_liboctave_error_handler) (
"matrix must be square");
894 volatile int typ = mattype.
type ();
900 typ = mattype.
type (*
this);
906 for (
F77_INT i = 0; i < nc; i++)
907 retval *=
elem (i, i);
917 anorm = norm1 (*
this);
922 F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
923 tmp_data, nr, tmp_info
924 F77_CHAR_ARG_LEN (1)));
943 F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
944 nr, tmp_data, nr, anorm,
945 rcon, pz, piz, tmp_info
946 F77_CHAR_ARG_LEN (1)));
954 for (
F77_INT i = 0; i < nc; i++)
955 retval *= atmp(i, i);
957 retval = retval.
square ();
961 (*current_liboctave_error_handler) (
"det: invalid dense matrix type");
977 anorm = norm1 (*
this);
979 F77_XFCN (dgetrf, DGETRF, (nr, nr, tmp_data, nr, pipvt, tmp_info));
1001 F77_XFCN (dgecon, DGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1002 nc, tmp_data, nr, anorm,
1003 rcon, pz, piz, tmp_info
1004 F77_CHAR_ARG_LEN (1)));
1016 for (
F77_INT i = 0; i < nc; i++)
1018 double c = atmp(i, i);
1019 retval *= (ipvt(i) != (i+1)) ? -c : c;
1032 return rcond (mattype);
1043 (*current_liboctave_error_handler) (
"matrix must be square");
1045 if (nr == 0 || nc == 0)
1049 volatile int typ = mattype.
type ();
1052 typ = mattype.
type (*
this);
1057 const double *tmp_data =
data ();
1068 F77_XFCN (dtrcon, DTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1069 F77_CONST_CHAR_ARG2 (&uplo, 1),
1070 F77_CONST_CHAR_ARG2 (&dia, 1),
1071 nr, tmp_data, nr, rcon,
1073 F77_CHAR_ARG_LEN (1)
1074 F77_CHAR_ARG_LEN (1)
1075 F77_CHAR_ARG_LEN (1)));
1081 (*current_liboctave_error_handler)
1082 (
"permuted triangular matrix not implemented");
1085 const double *tmp_data =
data ();
1096 F77_XFCN (dtrcon, DTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1097 F77_CONST_CHAR_ARG2 (&uplo, 1),
1098 F77_CONST_CHAR_ARG2 (&dia, 1),
1099 nr, tmp_data, nr, rcon,
1101 F77_CHAR_ARG_LEN (1)
1102 F77_CHAR_ARG_LEN (1)
1103 F77_CHAR_ARG_LEN (1)));
1109 (*current_liboctave_error_handler)
1110 (
"permuted triangular matrix not implemented");
1113 double anorm = -1.0;
1123 anorm = norm1 (atmp);
1125 F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1127 F77_CHAR_ARG_LEN (1)));
1142 F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1143 nr, tmp_data, nr, anorm,
1145 F77_CHAR_ARG_LEN (1)));
1163 anorm = norm1 (atmp);
1170 F77_XFCN (dgetrf, DGETRF, (nr, nr, tmp_data, nr, pipvt, info));
1180 F77_XFCN (dgecon, DGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1181 nc, tmp_data, nr, anorm,
1183 F77_CHAR_ARG_LEN (1)));
1199 double& rcon, solve_singularity_handler sing_handler,
1211 (*current_liboctave_error_handler)
1212 (
"matrix dimension mismatch solution of linear equations");
1214 if (nr == 0 || nc == 0 || b_nc == 0)
1215 retval =
Matrix (nc, b_nc, 0.0);
1218 volatile int typ = mattype.
type ();
1221 (*current_liboctave_error_handler) (
"incorrect matrix type");
1227 (*current_liboctave_error_handler)
1228 (
"permuted triangular matrix not implemented");
1230 const double *tmp_data =
data ();
1241 F77_XFCN (dtrtrs, DTRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1242 F77_CONST_CHAR_ARG2 (&trans, 1),
1243 F77_CONST_CHAR_ARG2 (&dia, 1),
1244 nr, b_nc, tmp_data, nr,
1245 result, nr, tmp_info
1246 F77_CHAR_ARG_LEN (1)
1247 F77_CHAR_ARG_LEN (1)
1248 F77_CHAR_ARG_LEN (1)));
1259 double *pz = z.fortran_vec ();
1261 F77_INT *piz = iz.fortran_vec ();
1263 F77_XFCN (dtrcon, DTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1264 F77_CONST_CHAR_ARG2 (&uplo, 1),
1265 F77_CONST_CHAR_ARG2 (&dia, 1),
1266 nr, tmp_data, nr, rcon,
1268 F77_CHAR_ARG_LEN (1)
1269 F77_CHAR_ARG_LEN (1)
1270 F77_CHAR_ARG_LEN (1)));
1278 volatile double rcond_plus_one = rcon + 1.0;
1285 sing_handler (rcon);
1297 double& rcon, solve_singularity_handler sing_handler,
1309 (*current_liboctave_error_handler)
1310 (
"matrix dimension mismatch solution of linear equations");
1312 if (nr == 0 || nc == 0 || b_nc == 0)
1313 retval =
Matrix (nc, b_nc, 0.0);
1316 volatile int typ = mattype.
type ();
1319 (*current_liboctave_error_handler) (
"incorrect matrix type");
1325 (*current_liboctave_error_handler)
1326 (
"permuted triangular matrix not implemented");
1328 const double *tmp_data =
data ();
1339 F77_XFCN (dtrtrs, DTRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1340 F77_CONST_CHAR_ARG2 (&trans, 1),
1341 F77_CONST_CHAR_ARG2 (&dia, 1),
1342 nr, b_nc, tmp_data, nr,
1343 result, nr, tmp_info
1344 F77_CHAR_ARG_LEN (1)
1345 F77_CHAR_ARG_LEN (1)
1346 F77_CHAR_ARG_LEN (1)));
1357 double *pz = z.fortran_vec ();
1359 F77_INT *piz = iz.fortran_vec ();
1361 F77_XFCN (dtrcon, DTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1362 F77_CONST_CHAR_ARG2 (&uplo, 1),
1363 F77_CONST_CHAR_ARG2 (&dia, 1),
1364 nr, tmp_data, nr, rcon,
1366 F77_CHAR_ARG_LEN (1)
1367 F77_CHAR_ARG_LEN (1)
1368 F77_CHAR_ARG_LEN (1)));
1375 volatile double rcond_plus_one = rcon + 1.0;
1382 sing_handler (rcon);
1394 double& rcon, solve_singularity_handler sing_handler,
1395 bool calc_cond)
const
1402 if (nr != nc || nr != b.
rows ())
1403 (*current_liboctave_error_handler)
1404 (
"matrix dimension mismatch solution of linear equations");
1406 if (nr == 0 || b.
cols () == 0)
1410 volatile int typ = mattype.
type ();
1413 double anorm = -1.0;
1425 anorm = norm1 (atmp);
1429 F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1430 tmp_data, nr, tmp_info
1431 F77_CHAR_ARG_LEN (1)));
1449 double *pz = z.fortran_vec ();
1451 F77_INT *piz = iz.fortran_vec ();
1453 F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1454 nr, tmp_data, nr, anorm,
1455 rcon, pz, piz, tmp_info
1456 F77_CHAR_ARG_LEN (1)));
1463 volatile double rcond_plus_one = rcon + 1.0;
1470 sing_handler (rcon);
1484 F77_XFCN (dpotrs, DPOTRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1485 nr, b_nc, tmp_data, nr,
1486 result, b_nr, tmp_info
1487 F77_CHAR_ARG_LEN (1)));
1504 F77_INT *pipvt = ipvt.fortran_vec ();
1509 if (calc_cond && anorm < 0.0)
1510 anorm = norm1 (atmp);
1513 double *pz = z.fortran_vec ();
1515 F77_INT *piz = iz.fortran_vec ();
1519 F77_XFCN (dgetrf, DGETRF, (nr, nr, tmp_data, nr, pipvt, tmp_info));
1530 sing_handler (rcon);
1542 F77_XFCN (dgecon, DGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1543 nc, tmp_data, nr, anorm,
1544 rcon, pz, piz, tmp_info
1545 F77_CHAR_ARG_LEN (1)));
1552 volatile double rcond_plus_one = rcon + 1.0;
1557 sing_handler (rcon);
1572 F77_XFCN (dgetrs, DGETRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1573 nr, b_nc, tmp_data, nr,
1574 pipvt, result, b_nr, tmp_info
1575 F77_CHAR_ARG_LEN (1)));
1584 (*current_liboctave_error_handler) (
"incorrect matrix type");
1595 return solve (mattype, b, info, rcon,
nullptr);
1603 return solve (mattype, b, info, rcon,
nullptr);
1610 return solve (mattype, b, info, rcon,
nullptr);
1615 double& rcon, solve_singularity_handler sing_handler,
1619 int typ = mattype.
type ();
1622 typ = mattype.
type (*
this);
1626 retval = utsolve (mattype, b, info, rcon, sing_handler,
true, transt);
1628 retval = ltsolve (mattype, b, info, rcon, sing_handler,
true, transt);
1633 retval = fsolve (mattype, b, info, rcon, sing_handler,
true);
1635 (*current_liboctave_error_handler) (
"unknown matrix type");
1641 retval =
lssolve (b, info, rank, rcon);
1652 return solve (mattype, b, info, rcon,
nullptr);
1660 return solve (mattype, b, info, rcon,
nullptr);
1667 return solve (mattype, b, info, rcon,
nullptr);
1688 unstack_complex_matrix (
const Matrix& sm)
1694 const double *smd = sm.
data ();
1697 rd[i] =
Complex (smd[i], smd[nel+i]);
1704 solve_singularity_handler sing_handler,
1707 Matrix tmp = stack_complex_matrix (b);
1708 tmp =
solve (mattype, tmp, info, rcon, sing_handler, singular_fallback,
1710 return unstack_complex_matrix (tmp);
1717 return solve (mattype, b, info, rcon);
1725 return solve (mattype, b, info, rcon);
1732 return solve (mattype, b, info, rcon,
nullptr);
1738 solve_singularity_handler sing_handler,
1742 tmp =
solve (mattype, tmp, info, rcon, sing_handler,
true, transt);
1750 return tmp.
solve (mattype, b);
1758 return tmp.
solve (mattype, b, info);
1766 return tmp.
solve (mattype, b, info, rcon);
1772 solve_singularity_handler sing_handler,
1776 return tmp.
solve (mattype, b, info, rcon, sing_handler, transt);
1784 return solve (b, info, rcon,
nullptr);
1791 return solve (b, info, rcon,
nullptr);
1797 return solve (b, info, rcon,
nullptr);
1802 double& rcon, solve_singularity_handler sing_handler,
1806 return solve (mattype, b, info, rcon, sing_handler,
true, transt);
1813 return tmp.
solve (b);
1820 return tmp.
solve (b, info);
1828 return tmp.
solve (b, info, rcon);
1833 solve_singularity_handler sing_handler,
1837 return tmp.
solve (b, info, rcon, sing_handler, transt);
1844 return solve (b, info, rcon);
1851 return solve (b, info, rcon);
1857 return solve (b, info, rcon,
nullptr);
1862 solve_singularity_handler sing_handler,
1866 return solve (mattype, b, info, rcon, sing_handler, transt);
1873 return tmp.
solve (b);
1880 return tmp.
solve (b, info);
1888 return tmp.
solve (b, info, rcon);
1894 solve_singularity_handler sing_handler,
1898 return tmp.
solve (b, info, rcon, sing_handler, transt);
1907 return lssolve (b, info, rank, rcon);
1915 return lssolve (b, info, rank, rcon);
1923 return lssolve (b, info, rank, rcon);
1940 (*current_liboctave_error_handler)
1941 (
"matrix dimension mismatch solution of linear equations");
1943 if (
m == 0 ||
n == 0 || b_nc == 0)
1944 retval =
Matrix (
n, b_nc, 0.0);
1952 retval =
Matrix (maxmn, nrhs, 0.0);
1954 for (
F77_INT j = 0; j < nrhs; j++)
1956 retval.
elem (i, j) = b.
elem (i, j);
1975 F77_CONST_CHAR_ARG2 (
" ", 1),
1977 F77_CHAR_ARG_LEN (6)
1978 F77_CHAR_ARG_LEN (1));
1982 F77_CONST_CHAR_ARG2 (
" ", 1),
1983 m,
n, nrhs, -1, mnthr
1984 F77_CHAR_ARG_LEN (6)
1985 F77_CHAR_ARG_LEN (1));
1989 double dminmn =
static_cast<double> (minmn);
1990 double dsmlsizp1 =
static_cast<double> (smlsiz+1);
1997 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2006 F77_XFCN (dgelsd, DGELSD, (
m,
n, nrhs, tmp_data,
m, pretval, maxmn,
2008 lwork, piwork, tmp_info));
2017 if (
n >
m &&
n >= mnthr)
2020 = 9*
m + 2*
m*smlsiz + 8*
m*nlvl +
m*nrhs + (smlsiz+1)*(smlsiz+1);
2033 if (wlalsd > addend)
2036 const F77_INT lworkaround = 4*
m +
m*
m + addend;
2038 if (work(0) < lworkaround)
2039 work(0) = lworkaround;
2044 = 12*
n + 2*
n*smlsiz + 8*
n*nlvl +
n*nrhs + (smlsiz+1)*(smlsiz+1);
2046 if (work(0) < lworkaround)
2047 work(0) = lworkaround;
2050 lwork =
static_cast<F77_INT> (work(0));
2053 double anorm = norm1 (*
this);
2058 retval =
Matrix (
n, b_nc, 0.0);
2067 F77_XFCN (dgelsd, DGELSD, (
m,
n, nrhs, tmp_data,
m, pretval,
2068 maxmn, ps, rcon, tmp_rank,
2075 if (s.
elem (0) == 0.0)
2078 rcon = s.
elem (minmn - 1) / s.
elem (0);
2094 return tmp.
lssolve (b, info, rank, rcon);
2103 return tmp.
lssolve (b, info, rank, rcon);
2112 return tmp.
lssolve (b, info, rank, rcon);
2120 return tmp.
lssolve (b, info, rank, rcon);
2129 return lssolve (b, info, rank, rcon);
2137 return lssolve (b, info, rank, rcon);
2145 return lssolve (b, info, rank, rcon);
2162 (*current_liboctave_error_handler)
2163 (
"matrix dimension mismatch solution of linear equations");
2165 if (
m == 0 ||
n == 0)
2197 F77_CONST_CHAR_ARG2 (
" ", 1),
2199 F77_CHAR_ARG_LEN (6)
2200 F77_CHAR_ARG_LEN (1));
2204 double dminmn =
static_cast<double> (minmn);
2205 double dsmlsizp1 =
static_cast<double> (smlsiz+1);
2212 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2221 F77_XFCN (dgelsd, DGELSD, (
m,
n, nrhs, tmp_data,
m, pretval, maxmn,
2223 lwork, piwork, tmp_info));
2228 lwork =
static_cast<F77_INT> (work(0));
2231 F77_XFCN (dgelsd, DGELSD, (
m,
n, nrhs, tmp_data,
m, pretval,
2232 maxmn, ps, rcon, tmp_rank,
2241 if (s.
elem (0) == 0.0)
2244 rcon = s.
elem (minmn - 1) / s.
elem (0);
2260 return tmp.
lssolve (b, info, rank, rcon);
2269 return tmp.
lssolve (b, info, rank, rcon);
2278 return tmp.
lssolve (b, info, rank, rcon);
2286 return tmp.
lssolve (b, info, rank, rcon);
2298 if (nr != a_nr || nc != a_nc)
2316 if (nr != a_nr || nc != a_nc)
2343 F77_XFCN (dgemm, DGEMM, (F77_CONST_CHAR_ARG2 (
"N", 1),
2344 F77_CONST_CHAR_ARG2 (
"N", 1),
2347 F77_CHAR_ARG_LEN (1)
2348 F77_CHAR_ARG_LEN (1)));
2420 if (nr == 1 || nc == 1)
2443 if (nr > 0 && nc > 0)
2454 for (idx_j = 0; idx_j < nc; idx_j++)
2456 tmp_min =
elem (i, idx_j);
2464 double tmp =
elem (i, j);
2468 else if (tmp < tmp_min)
2475 result.
elem (i) = tmp_min;
2498 if (nr > 0 && nc > 0)
2509 for (idx_j = 0; idx_j < nc; idx_j++)
2511 tmp_max =
elem (i, idx_j);
2519 double tmp =
elem (i, j);
2523 else if (tmp > tmp_max)
2530 result.
elem (i) = tmp_max;
2553 if (nr > 0 && nc > 0)
2564 for (idx_i = 0; idx_i < nr; idx_i++)
2566 tmp_min =
elem (idx_i, j);
2574 double tmp =
elem (i, j);
2578 else if (tmp < tmp_min)
2585 result.
elem (j) = tmp_min;
2608 if (nr > 0 && nc > 0)
2619 for (idx_i = 0; idx_i < nr; idx_i++)
2621 tmp_max =
elem (idx_i, j);
2629 double tmp =
elem (i, j);
2633 else if (tmp > tmp_max)
2640 result.
elem (j) = tmp_max;
2656 octave::write_value<double> (os, a.
elem (i, j));
2669 if (nr > 0 && nc > 0)
2675 tmp = octave::read_value<double> (is);
2677 a.
elem (i, j) = tmp;
2689 double cc, s, temp_r;
2691 F77_FUNC (dlartg, DLARTG) (
x, y, cc, s, temp_r);
2712 octave::math::schur<Matrix> as (a,
"U");
2713 octave::math::schur<Matrix> bs (b,
"U");
2717 Matrix ua = as.unitary_schur_matrix ();
2718 Matrix sch_a = as.schur_matrix ();
2720 Matrix ub = bs.unitary_schur_matrix ();
2721 Matrix sch_b = bs.schur_matrix ();
2737 F77_XFCN (dtrsyl, DTRSYL, (F77_CONST_CHAR_ARG2 (
"N", 1),
2738 F77_CONST_CHAR_ARG2 (
"N", 1),
2739 1, a_nr, b_nr, pa, a_nr, pb,
2740 b_nr, px, a_nr,
scale, info
2741 F77_CHAR_ARG_LEN (1)
2742 F77_CHAR_ARG_LEN (1)));
2778 get_blas_trans_arg (
bool trans)
2780 return trans ?
'T' :
'N';
2803 if (a_nr == 0 || a_nc == 0 || b_nc == 0)
2804 retval =
Matrix (a_nr, b_nc, 0.0);
2805 else if (a.
data () == b.
data () && a_nr == b_nc && tra != trb)
2809 retval =
Matrix (a_nr, b_nc);
2812 const char ctra = get_blas_trans_arg (tra);
2813 F77_XFCN (dsyrk, DSYRK, (F77_CONST_CHAR_ARG2 (
"U", 1),
2814 F77_CONST_CHAR_ARG2 (&ctra, 1),
2816 a.
data (), lda, 0.0, c, a_nr
2817 F77_CHAR_ARG_LEN (1)
2818 F77_CHAR_ARG_LEN (1)));
2819 for (
int j = 0; j < a_nr; j++)
2820 for (
int i = 0; i < j; i++)
2831 retval =
Matrix (a_nr, b_nc);
2840 const char ctra = get_blas_trans_arg (tra);
2841 F77_XFCN (dgemv, DGEMV, (F77_CONST_CHAR_ARG2 (&ctra, 1),
2842 lda, tda, 1.0, a.
data (), lda,
2843 b.
data (), 1, 0.0, c, 1
2844 F77_CHAR_ARG_LEN (1)));
2849 const char crevtrb = get_blas_trans_arg (! trb);
2850 F77_XFCN (dgemv, DGEMV, (F77_CONST_CHAR_ARG2 (&crevtrb, 1),
2851 ldb, tdb, 1.0, b.
data (), ldb,
2852 a.
data (), 1, 0.0, c, 1
2853 F77_CHAR_ARG_LEN (1)));
2857 const char ctra = get_blas_trans_arg (tra);
2858 const char ctrb = get_blas_trans_arg (trb);
2859 F77_XFCN (dgemm, DGEMM, (F77_CONST_CHAR_ARG2 (&ctra, 1),
2860 F77_CONST_CHAR_ARG2 (&ctrb, 1),
2861 a_nr, b_nc, a_nc, 1.0, a.
data (),
2862 lda, b.
data (), ldb, 0.0, c, a_nr
2863 F77_CHAR_ARG_LEN (1)
2864 F77_CHAR_ARG_LEN (1)));
2874 return xgemm (a, b);
2879 #define EMPTY_RETURN_CHECK(T) \
2880 if (nr == 0 || nc == 0) \
2930 (*current_liboctave_error_handler)
2931 (
"two-arg min requires same size arguments");
2994 (*current_liboctave_error_handler)
2995 (
"two-arg max requires same size arguments");
3020 (*current_liboctave_error_handler)
3021 (
"linspace: vectors must be of equal length");
3031 retval.clear (
m,
n);
3033 retval.insert (
linspace (x1(i), x2(i),
n), i, 0);
double & elem(octave_idx_type n)
T * fortran_vec()
Size of the specified dimension.
Array< double, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
octave_idx_type rows() const
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Array< T, Alloc > & insert(const Array< T, Alloc > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
const double * data() const
octave_idx_type columns() const
octave_idx_type cols() const
double & xelem(octave_idx_type n)
octave_idx_type numel() const
Number of elements in the array.
void resize(octave_idx_type n, const double &rfv=0)
ColumnVector extract(octave_idx_type r1, octave_idx_type r2) const
ComplexMatrix lssolve(const Matrix &b) const
ComplexMatrix solve(MatrixType &mattype, const Matrix &b) const
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 pseudo_inverse(double tol=0.0) const
Matrix & fill(double val)
ComplexMatrix fourier() const
Matrix diag(octave_idx_type k=0) const
boolMatrix all(int dim=-1) const
ComplexMatrix fourier2d() const
Matrix sum(int dim=-1) const
ComplexMatrix ifourier2d() const
Matrix sumsq(int dim=-1) const
Matrix & insert(const Matrix &a, octave_idx_type r, octave_idx_type c)
Matrix prod(int dim=-1) const
RowVector row(octave_idx_type i) const
Matrix stack(const Matrix &a) const
Matrix append(const Matrix &a) const
Matrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
ComplexMatrix ifourier() const
RowVector column_min() const
Matrix cumprod(int dim=-1) const
RowVector column_max() const
Matrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
Matrix & operator+=(const DiagMatrix &a)
boolMatrix any(int dim=-1) const
Matrix & operator-=(const DiagMatrix &a)
friend class ComplexMatrix
bool operator==(const Matrix &a) const
Matrix solve(MatrixType &mattype, const Matrix &b) const
ColumnVector row_min() const
Matrix cumsum(int dim=-1) const
bool operator!=(const Matrix &a) const
Matrix lssolve(const Matrix &b) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
ColumnVector row_max() const
ColumnVector column(octave_idx_type i) const
NDArray diag(octave_idx_type k=0) const
NDArray cumsum(int dim=-1) const
NDArray sumsq(int dim=-1) const
NDArray prod(int dim=-1) const
NDArray cumprod(int dim=-1) const
boolNDArray all(int dim=-1) const
boolNDArray any(int dim=-1) const
NDArray sum(int dim=-1) const
octave_idx_type rows() const
const Array< octave_idx_type > & col_perm_vec() const
void resize(octave_idx_type n, const double &rfv=0)
Vector representing the dimensions (size) of an Array.
Matrix imag(const ComplexMatrix &a)
std::ostream & operator<<(std::ostream &os, const Matrix &a)
Matrix xgemm(const Matrix &a, const Matrix &b, blas_trans_type transa, blas_trans_type transb)
std::istream & operator>>(std::istream &is, Matrix &a)
Matrix Givens(double x, double y)
Matrix max(double d, const Matrix &m)
Matrix Sylvester(const Matrix &a, const Matrix &b, const Matrix &c)
Matrix operator*(const ColumnVector &v, const RowVector &a)
#define EMPTY_RETURN_CHECK(T)
Matrix linspace(const ColumnVector &x1, const ColumnVector &x2, octave_idx_type n)
Matrix min(double d, const Matrix &m)
Matrix real(const ComplexMatrix &a)
#define F77_XFCN(f, F, args)
octave_f77_int_type F77_INT
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)
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
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)
bool mx_inline_equal(std::size_t n, const T1 *x, const T2 *y)
void mx_inline_real(std::size_t n, T *r, const std::complex< T > *x)
void mx_inline_imag(std::size_t n, T *r, const std::complex< T > *x)
#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)
subroutine xddot(n, dx, incx, dy, 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)