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,
576 lwork =
static_cast<F77_INT> (z(0));
577 lwork = (lwork < 4 * nc ? 4 * nc : lwork);
587 anorm =
norm1 (retval);
589 F77_XFCN (dgetrf, DGETRF, (nc, nc, tmp_data, nr, pipvt, tmp_info));
605 F77_XFCN (dgecon, DGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
606 nc, tmp_data, nr, anorm,
607 rcon, pz, piz, dgecon_info
608 F77_CHAR_ARG_LEN (1)));
610 if (dgecon_info != 0)
614 if (info == -1 && ! force)
620 F77_XFCN (dgetri, DGETRI, (nc, tmp_data, nr, pipvt,
621 pz, lwork, dgetri_info));
623 if (dgetri_info != 0)
635 bool force,
bool calc_cond)
const
637 int typ = mattype.
type (
false);
641 typ = mattype.
type (*
this);
658 ret =
tinverse (mattype, info, rcon, force, calc_cond);
667 rcon =
chol.rcond ();
670 ret =
chol.inverse ();
677 ret =
finverse (mattype, info, rcon, force, calc_cond);
679 if ((calc_cond || mattype.
ishermitian ()) && rcon == 0.0)
706 * std::numeric_limits<double>::epsilon ();
712 while (r >= 0 && sigma.
elem (r) < tol)
716 return Matrix (nc, nr, 0.0);
721 Matrix Vr =
V.extract (0, 0, nc-1, r);
726#if defined (HAVE_FFTW)
731 std::size_t nr =
rows ();
732 std::size_t nc =
cols ();
736 std::size_t npts, nsamples;
738 if (nr == 1 || nc == 1)
740 npts = (nr > nc ? nr : nc);
749 const double *in (
data ());
760 std::size_t nr =
rows ();
761 std::size_t nc =
cols ();
765 std::size_t npts, nsamples;
767 if (nr == 1 || nc == 1)
769 npts = (nr > nc ? nr : nc);
792 const double *in =
data ();
817 (*current_liboctave_error_handler)
818 (
"support for FFTW was unavailable or disabled when liboctave was built");
826 (*current_liboctave_error_handler)
827 (
"support for FFTW was unavailable or disabled when liboctave was built");
835 (*current_liboctave_error_handler)
836 (
"support for FFTW was unavailable or disabled when liboctave was built");
844 (*current_liboctave_error_handler)
845 (
"support for FFTW was unavailable or disabled when liboctave was built");
871 return determinant (mattype, info, rcon, calc_cond);
887 (*current_liboctave_error_handler) (
"matrix must be square");
889 volatile int typ = mattype.
type ();
895 typ = mattype.
type (*
this);
901 for (
F77_INT i = 0; i < nc; i++)
902 retval *=
elem (i, i);
912 anorm =
norm1 (*
this);
917 F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
918 tmp_data, nr, tmp_info
919 F77_CHAR_ARG_LEN (1)));
938 F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
939 nr, tmp_data, nr, anorm,
940 rcon, pz, piz, tmp_info
941 F77_CHAR_ARG_LEN (1)));
949 for (
F77_INT i = 0; i < nc; i++)
950 retval *= atmp(i, i);
952 retval = retval.
square ();
956 (*current_liboctave_error_handler) (
"det: invalid dense matrix type");
972 anorm =
norm1 (*
this);
974 F77_XFCN (dgetrf, DGETRF, (nr, nr, tmp_data, nr, pipvt, tmp_info));
996 F77_XFCN (dgecon, DGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
997 nc, tmp_data, nr, anorm,
998 rcon, pz, piz, tmp_info
999 F77_CHAR_ARG_LEN (1)));
1011 for (
F77_INT i = 0; i < nc; i++)
1013 double c = atmp(i, i);
1014 retval *= (ipvt(i) != (i+1)) ? -c : c;
1027 return rcond (mattype);
1038 (*current_liboctave_error_handler) (
"matrix must be square");
1040 if (nr == 0 || nc == 0)
1044 volatile int typ = mattype.
type ();
1047 typ = mattype.
type (*
this);
1052 const double *tmp_data =
data ();
1063 F77_XFCN (dtrcon, DTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1064 F77_CONST_CHAR_ARG2 (&uplo, 1),
1065 F77_CONST_CHAR_ARG2 (&dia, 1),
1066 nr, tmp_data, nr, rcon,
1068 F77_CHAR_ARG_LEN (1)
1069 F77_CHAR_ARG_LEN (1)
1070 F77_CHAR_ARG_LEN (1)));
1076 (*current_liboctave_error_handler)
1077 (
"permuted triangular matrix not implemented");
1080 const double *tmp_data =
data ();
1091 F77_XFCN (dtrcon, DTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1092 F77_CONST_CHAR_ARG2 (&uplo, 1),
1093 F77_CONST_CHAR_ARG2 (&dia, 1),
1094 nr, tmp_data, nr, rcon,
1096 F77_CHAR_ARG_LEN (1)
1097 F77_CHAR_ARG_LEN (1)
1098 F77_CHAR_ARG_LEN (1)));
1104 (*current_liboctave_error_handler)
1105 (
"permuted triangular matrix not implemented");
1108 double anorm = -1.0;
1118 anorm =
norm1 (atmp);
1120 F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1122 F77_CHAR_ARG_LEN (1)));
1137 F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1138 nr, tmp_data, nr, anorm,
1140 F77_CHAR_ARG_LEN (1)));
1158 anorm =
norm1 (atmp);
1165 F77_XFCN (dgetrf, DGETRF, (nr, nr, tmp_data, nr, pipvt, info));
1175 F77_XFCN (dgecon, DGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1176 nc, tmp_data, nr, anorm,
1178 F77_CHAR_ARG_LEN (1)));
1194 double& rcon, solve_singularity_handler sing_handler,
1206 (*current_liboctave_error_handler)
1207 (
"matrix dimension mismatch solution of linear equations");
1209 if (nr == 0 || nc == 0 || b_nc == 0)
1210 retval =
Matrix (nc, b_nc, 0.0);
1213 volatile int typ = mattype.
type ();
1216 (*current_liboctave_error_handler) (
"incorrect matrix type");
1222 (*current_liboctave_error_handler)
1223 (
"permuted triangular matrix not implemented");
1225 const double *tmp_data =
data ();
1236 F77_XFCN (dtrtrs, DTRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1237 F77_CONST_CHAR_ARG2 (&trans, 1),
1238 F77_CONST_CHAR_ARG2 (&dia, 1),
1239 nr, b_nc, tmp_data, nr,
1240 result, nr, tmp_info
1241 F77_CHAR_ARG_LEN (1)
1242 F77_CHAR_ARG_LEN (1)
1243 F77_CHAR_ARG_LEN (1)));
1258 F77_XFCN (dtrcon, DTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1259 F77_CONST_CHAR_ARG2 (&uplo, 1),
1260 F77_CONST_CHAR_ARG2 (&dia, 1),
1261 nr, tmp_data, nr, rcon,
1263 F77_CHAR_ARG_LEN (1)
1264 F77_CHAR_ARG_LEN (1)
1265 F77_CHAR_ARG_LEN (1)));
1273 volatile double rcond_plus_one = rcon + 1.0;
1280 sing_handler (rcon);
1292 double& rcon, solve_singularity_handler sing_handler,
1304 (*current_liboctave_error_handler)
1305 (
"matrix dimension mismatch solution of linear equations");
1307 if (nr == 0 || nc == 0 || b_nc == 0)
1308 retval =
Matrix (nc, b_nc, 0.0);
1311 volatile int typ = mattype.
type ();
1314 (*current_liboctave_error_handler) (
"incorrect matrix type");
1320 (*current_liboctave_error_handler)
1321 (
"permuted triangular matrix not implemented");
1323 const double *tmp_data =
data ();
1334 F77_XFCN (dtrtrs, DTRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1335 F77_CONST_CHAR_ARG2 (&trans, 1),
1336 F77_CONST_CHAR_ARG2 (&dia, 1),
1337 nr, b_nc, tmp_data, nr,
1338 result, nr, tmp_info
1339 F77_CHAR_ARG_LEN (1)
1340 F77_CHAR_ARG_LEN (1)
1341 F77_CHAR_ARG_LEN (1)));
1356 F77_XFCN (dtrcon, DTRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1357 F77_CONST_CHAR_ARG2 (&uplo, 1),
1358 F77_CONST_CHAR_ARG2 (&dia, 1),
1359 nr, tmp_data, nr, rcon,
1361 F77_CHAR_ARG_LEN (1)
1362 F77_CHAR_ARG_LEN (1)
1363 F77_CHAR_ARG_LEN (1)));
1370 volatile double rcond_plus_one = rcon + 1.0;
1377 sing_handler (rcon);
1389 double& rcon, solve_singularity_handler sing_handler,
1390 bool calc_cond)
const
1397 if (nr != nc || nr != b.
rows ())
1398 (*current_liboctave_error_handler)
1399 (
"matrix dimension mismatch solution of linear equations");
1401 if (nr == 0 || b.
cols () == 0)
1405 volatile int typ = mattype.
type ();
1408 double anorm = -1.0;
1420 anorm =
norm1 (atmp);
1424 F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1425 tmp_data, nr, tmp_info
1426 F77_CHAR_ARG_LEN (1)));
1448 F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1449 nr, tmp_data, nr, anorm,
1450 rcon, pz, piz, tmp_info
1451 F77_CHAR_ARG_LEN (1)));
1458 volatile double rcond_plus_one = rcon + 1.0;
1465 sing_handler (rcon);
1479 F77_XFCN (dpotrs, DPOTRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1480 nr, b_nc, tmp_data, nr,
1481 result, b_nr, tmp_info
1482 F77_CHAR_ARG_LEN (1)));
1504 if (calc_cond && anorm < 0.0)
1505 anorm =
norm1 (atmp);
1514 F77_XFCN (dgetrf, DGETRF, (nr, nr, tmp_data, nr, pipvt, tmp_info));
1525 sing_handler (rcon);
1537 F77_XFCN (dgecon, DGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1538 nc, tmp_data, nr, anorm,
1539 rcon, pz, piz, tmp_info
1540 F77_CHAR_ARG_LEN (1)));
1547 volatile double rcond_plus_one = rcon + 1.0;
1552 sing_handler (rcon);
1567 F77_XFCN (dgetrs, DGETRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1568 nr, b_nc, tmp_data, nr,
1569 pipvt, result, b_nr, tmp_info
1570 F77_CHAR_ARG_LEN (1)));
1579 (*current_liboctave_error_handler) (
"incorrect matrix type");
1590 return solve (mattype, b, info, rcon,
nullptr);
1598 return solve (mattype, b, info, rcon,
nullptr);
1605 return solve (mattype, b, info, rcon,
nullptr);
1610 double& rcon, solve_singularity_handler sing_handler,
1614 int typ = mattype.
type ();
1617 typ = mattype.
type (*
this);
1621 retval =
utsolve (mattype, b, info, rcon, sing_handler,
true, transt);
1623 retval =
ltsolve (mattype, b, info, rcon, sing_handler,
true, transt);
1628 retval =
fsolve (mattype, b, info, rcon, sing_handler,
true);
1630 (*current_liboctave_error_handler) (
"unknown matrix type");
1636 retval =
lssolve (b, info, rank, rcon);
1647 return solve (mattype, b, info, rcon,
nullptr);
1655 return solve (mattype, b, info, rcon,
nullptr);
1662 return solve (mattype, b, info, rcon,
nullptr);
1689 const double *smd = sm.
data ();
1692 rd[i] =
Complex (smd[i], smd[nel+i]);
1699 solve_singularity_handler sing_handler,
1703 tmp =
solve (mattype, tmp, info, rcon, sing_handler, singular_fallback,
1712 return solve (mattype, b, info, rcon);
1720 return solve (mattype, b, info, rcon);
1727 return solve (mattype, b, info, rcon,
nullptr);
1733 solve_singularity_handler sing_handler,
1737 tmp =
solve (mattype, tmp, info, rcon, sing_handler,
true, transt);
1745 return tmp.
solve (mattype, b);
1753 return tmp.
solve (mattype, b, info);
1761 return tmp.
solve (mattype, b, info, rcon);
1767 solve_singularity_handler sing_handler,
1771 return tmp.
solve (mattype, b, info, rcon, sing_handler, transt);
1779 return solve (b, info, rcon,
nullptr);
1786 return solve (b, info, rcon,
nullptr);
1792 return solve (b, info, rcon,
nullptr);
1797 double& rcon, solve_singularity_handler sing_handler,
1801 return solve (mattype, b, info, rcon, sing_handler,
true, transt);
1808 return tmp.
solve (b);
1815 return tmp.
solve (b, info);
1823 return tmp.
solve (b, info, rcon);
1828 solve_singularity_handler sing_handler,
1832 return tmp.
solve (b, info, rcon, sing_handler, transt);
1839 return solve (b, info, rcon);
1846 return solve (b, info, rcon);
1852 return solve (b, info, rcon,
nullptr);
1857 solve_singularity_handler sing_handler,
1861 return solve (mattype, b, info, rcon, sing_handler, transt);
1868 return tmp.
solve (b);
1875 return tmp.
solve (b, info);
1883 return tmp.
solve (b, info, rcon);
1889 solve_singularity_handler sing_handler,
1893 return tmp.
solve (b, info, rcon, sing_handler, transt);
1902 return lssolve (b, info, rank, rcon);
1910 return lssolve (b, info, rank, rcon);
1918 return lssolve (b, info, rank, rcon);
1935 (*current_liboctave_error_handler)
1936 (
"matrix dimension mismatch solution of linear equations");
1938 if (m == 0 || n == 0 || b_nc == 0)
1939 retval =
Matrix (n, b_nc, 0.0);
1942 volatile F77_INT minmn = (m < n ? m : n);
1943 F77_INT maxmn = (m > n ? m : n);
1947 retval =
Matrix (maxmn, nrhs, 0.0);
1949 for (
F77_INT j = 0; j < nrhs; j++)
1950 for (
F77_INT i = 0; i < m; i++)
1951 retval.
elem (i, j) = b.
elem (i, j);
1970 F77_CONST_CHAR_ARG2 (
" ", 1),
1972 F77_CHAR_ARG_LEN (6)
1973 F77_CHAR_ARG_LEN (1));
1977 F77_CONST_CHAR_ARG2 (
" ", 1),
1978 m, n, nrhs, -1, mnthr
1979 F77_CHAR_ARG_LEN (6)
1980 F77_CHAR_ARG_LEN (1));
1984 double dminmn =
static_cast<double> (minmn);
1985 double dsmlsizp1 =
static_cast<double> (smlsiz+1);
1992 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2001 F77_XFCN (dgelsd, DGELSD, (m, n, nrhs, tmp_data, m, pretval, maxmn,
2003 lwork, piwork, tmp_info));
2012 if (n > m && n >= mnthr)
2015 = 9*m + 2*m*smlsiz + 8*m*nlvl + m*nrhs + (smlsiz+1)*(smlsiz+1);
2028 if (wlalsd > addend)
2031 const F77_INT lworkaround = 4*m + m*m + addend;
2033 if (work(0) < lworkaround)
2034 work(0) = lworkaround;
2039 = 12*n + 2*n*smlsiz + 8*n*nlvl + n*nrhs + (smlsiz+1)*(smlsiz+1);
2041 if (work(0) < lworkaround)
2042 work(0) = lworkaround;
2045 lwork =
static_cast<F77_INT> (work(0));
2048 double anorm =
norm1 (*
this);
2053 retval =
Matrix (n, b_nc, 0.0);
2062 F77_XFCN (dgelsd, DGELSD, (m, n, nrhs, tmp_data, m, pretval,
2063 maxmn, ps, rcon, tmp_rank,
2070 if (s.
elem (0) == 0.0)
2073 rcon = s.
elem (minmn - 1) / s.
elem (0);
2089 return tmp.
lssolve (b, info, rank, rcon);
2098 return tmp.
lssolve (b, info, rank, rcon);
2107 return tmp.
lssolve (b, info, rank, rcon);
2115 return tmp.
lssolve (b, info, rank, rcon);
2124 return lssolve (b, info, rank, rcon);
2132 return lssolve (b, info, rank, rcon);
2140 return lssolve (b, info, rank, rcon);
2157 (*current_liboctave_error_handler)
2158 (
"matrix dimension mismatch solution of linear equations");
2160 if (m == 0 || n == 0)
2164 volatile F77_INT minmn = (m < n ? m : n);
2165 F77_INT maxmn = (m > n ? m : n);
2172 for (
F77_INT i = 0; i < m; i++)
2192 F77_CONST_CHAR_ARG2 (
" ", 1),
2194 F77_CHAR_ARG_LEN (6)
2195 F77_CHAR_ARG_LEN (1));
2199 double dminmn =
static_cast<double> (minmn);
2200 double dsmlsizp1 =
static_cast<double> (smlsiz+1);
2207 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2216 F77_XFCN (dgelsd, DGELSD, (m, n, nrhs, tmp_data, m, pretval, maxmn,
2218 lwork, piwork, tmp_info));
2223 lwork =
static_cast<F77_INT> (work(0));
2226 F77_XFCN (dgelsd, DGELSD, (m, n, nrhs, tmp_data, m, pretval,
2227 maxmn, ps, rcon, tmp_rank,
2236 if (s.
elem (0) == 0.0)
2239 rcon = s.
elem (minmn - 1) / s.
elem (0);
2255 return tmp.
lssolve (b, info, rank, rcon);
2264 return tmp.
lssolve (b, info, rank, rcon);
2273 return tmp.
lssolve (b, info, rank, rcon);
2281 return tmp.
lssolve (b, info, rank, rcon);
2293 if (nr != a_nr || nc != a_nc)
2311 if (nr != a_nr || nc != a_nc)
2338 F77_XFCN (dgemm, DGEMM, (F77_CONST_CHAR_ARG2 (
"N", 1),
2339 F77_CONST_CHAR_ARG2 (
"N", 1),
2342 F77_CHAR_ARG_LEN (1)
2343 F77_CHAR_ARG_LEN (1)));
2415 if (nr == 1 || nc == 1)
2438 if (nr > 0 && nc > 0)
2449 for (idx_j = 0; idx_j < nc; idx_j++)
2451 tmp_min =
elem (i, idx_j);
2459 double tmp =
elem (i, j);
2463 else if (tmp < tmp_min)
2470 result.
elem (i) = tmp_min;
2493 if (nr > 0 && nc > 0)
2504 for (idx_j = 0; idx_j < nc; idx_j++)
2506 tmp_max =
elem (i, idx_j);
2514 double tmp =
elem (i, j);
2518 else if (tmp > tmp_max)
2525 result.
elem (i) = tmp_max;
2548 if (nr > 0 && nc > 0)
2559 for (idx_i = 0; idx_i < nr; idx_i++)
2561 tmp_min =
elem (idx_i, j);
2569 double tmp =
elem (i, j);
2573 else if (tmp < tmp_min)
2580 result.
elem (j) = tmp_min;
2603 if (nr > 0 && nc > 0)
2614 for (idx_i = 0; idx_i < nr; idx_i++)
2616 tmp_max =
elem (idx_i, j);
2624 double tmp =
elem (i, j);
2628 else if (tmp > tmp_max)
2635 result.
elem (j) = tmp_max;
2651 octave::write_value<double> (os, a.
elem (i, j));
2664 if (nr > 0 && nc > 0)
2670 tmp = octave::read_value<double> (is);
2672 a.
elem (i, j) = tmp;
2684 double cc, s, temp_r;
2686 F77_FUNC (dlartg, DLARTG) (
x, y, cc, s, temp_r);
2732 F77_XFCN (dtrsyl, DTRSYL, (F77_CONST_CHAR_ARG2 (
"N", 1),
2733 F77_CONST_CHAR_ARG2 (
"N", 1),
2734 1, a_nr, b_nr, pa, a_nr, pb,
2735 b_nr, px, a_nr,
scale, info
2736 F77_CHAR_ARG_LEN (1)
2737 F77_CHAR_ARG_LEN (1)));
2775 return trans ?
'T' :
'N';
2798 if (a_nr == 0 || a_nc == 0 || b_nc == 0)
2799 retval =
Matrix (a_nr, b_nc, 0.0);
2800 else if (a.
data () == b.
data () && a_nr == b_nc && tra != trb)
2804 retval =
Matrix (a_nr, b_nc);
2808 F77_XFCN (dsyrk, DSYRK, (F77_CONST_CHAR_ARG2 (
"U", 1),
2809 F77_CONST_CHAR_ARG2 (&ctra, 1),
2811 a.
data (), lda, 0.0, c, a_nr
2812 F77_CHAR_ARG_LEN (1)
2813 F77_CHAR_ARG_LEN (1)));
2814 for (
int j = 0; j < a_nr; j++)
2815 for (
int i = 0; i < j; i++)
2826 retval =
Matrix (a_nr, b_nc);
2836 F77_XFCN (dgemv, DGEMV, (F77_CONST_CHAR_ARG2 (&ctra, 1),
2837 lda, tda, 1.0, a.
data (), lda,
2838 b.
data (), 1, 0.0, c, 1
2839 F77_CHAR_ARG_LEN (1)));
2845 F77_XFCN (dgemv, DGEMV, (F77_CONST_CHAR_ARG2 (&crevtrb, 1),
2846 ldb, tdb, 1.0, b.
data (), ldb,
2847 a.
data (), 1, 0.0, c, 1
2848 F77_CHAR_ARG_LEN (1)));
2854 F77_XFCN (dgemm, DGEMM, (F77_CONST_CHAR_ARG2 (&ctra, 1),
2855 F77_CONST_CHAR_ARG2 (&ctrb, 1),
2856 a_nr, b_nc, a_nc, 1.0, a.
data (),
2857 lda, b.
data (), ldb, 0.0, c, a_nr
2858 F77_CHAR_ARG_LEN (1)
2859 F77_CHAR_ARG_LEN (1)));
2869 return xgemm (a, b);
2874#define EMPTY_RETURN_CHECK(T) \
2875 if (nr == 0 || nc == 0) \
2925 (*current_liboctave_error_handler)
2926 (
"two-arg min requires same size arguments");
2989 (*current_liboctave_error_handler)
2990 (
"two-arg max requires same size arguments");
3013 if (x2.
numel () != m)
3014 (*current_liboctave_error_handler)
3015 (
"linspace: vectors must be of equal length");
3021 retval.
clear (m, 0);
3025 retval.clear (m, n);
3027 retval.xelem (i, 0) = x1(i);
3030 double *delta = &retval.xelem (0, n-1);
3032 delta[i] = (x1(i) == x2(i)) ? 0 : (x2(i) - x1(i)) / (n - 1);
3036 retval.xelem (i, j) = x1(i) + j*delta[i];
3039 retval.xelem (i, n-1) = x2(i);
bool issquare(void) const
double & xelem(octave_idx_type n)
OCTARRAY_API void clear(void)
OCTARRAY_API Array< double, 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
double & 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 double * data(void) const
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
void resize(octave_idx_type n, const double &rfv=0)
OCTAVE_API ColumnVector extract(octave_idx_type r1, octave_idx_type r2) const
OCTAVE_API ComplexMatrix lssolve(const Matrix &b) const
OCTAVE_API ComplexMatrix solve(MatrixType &mattype, const Matrix &b) const
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 pseudo_inverse(double tol=0.0) const
OCTAVE_API Matrix & fill(double val)
OCTAVE_API Matrix diag(octave_idx_type k=0) const
Matrix ltsolve(MatrixType &mattype, const Matrix &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 fourier(void) const
OCTAVE_API ComplexMatrix fourier2d(void) const
OCTAVE_API RowVector column_min(void) const
OCTAVE_API boolMatrix all(int dim=-1) const
OCTAVE_API ColumnVector row_max(void) const
OCTAVE_API Matrix sum(int dim=-1) const
OCTAVE_API double rcond(void) const
OCTAVE_API Matrix sumsq(int dim=-1) const
OCTAVE_API Matrix & insert(const Matrix &a, octave_idx_type r, octave_idx_type c)
OCTAVE_API Matrix prod(int dim=-1) const
OCTAVE_API RowVector row(octave_idx_type i) const
OCTAVE_API Matrix stack(const Matrix &a) const
OCTAVE_API Matrix append(const Matrix &a) const
Matrix fsolve(MatrixType &mattype, const Matrix &b, octave_idx_type &info, double &rcon, solve_singularity_handler sing_handler, bool calc_cond=false) const
OCTAVE_API Matrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
OCTAVE_API RowVector column_max(void) const
Matrix utsolve(MatrixType &mattype, const Matrix &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 Matrix cumprod(int dim=-1) const
OCTAVE_API Matrix inverse(void) const
Matrix tinverse(MatrixType &mattype, octave_idx_type &info, double &rcon, bool force, bool calc_cond) const
OCTAVE_API Matrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
OCTAVE_API Matrix abs(void) const
OCTAVE_API Matrix & operator+=(const DiagMatrix &a)
OCTAVE_API bool issymmetric(void) const
OCTAVE_API boolMatrix any(int dim=-1) const
OCTAVE_API ColumnVector row_min(void) const
OCTAVE_API Matrix & operator-=(const DiagMatrix &a)
OCTAVE_API ComplexMatrix ifourier2d(void) const
friend class ComplexMatrix
Matrix transpose(void) const
OCTAVE_API ComplexMatrix ifourier(void) const
OCTAVE_API DET determinant(void) const
Matrix finverse(MatrixType &mattype, octave_idx_type &info, double &rcon, bool force, bool calc_cond) const
OCTAVE_API bool operator==(const Matrix &a) const
OCTAVE_API Matrix solve(MatrixType &mattype, const Matrix &b) const
OCTAVE_API Matrix cumsum(int dim=-1) const
OCTAVE_API bool operator!=(const Matrix &a) const
OCTAVE_API Matrix lssolve(const Matrix &b) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
OCTAVE_API ColumnVector column(octave_idx_type i) const
OCTAVE_API NDArray diag(octave_idx_type k=0) const
OCTAVE_API NDArray abs(void) const
OCTAVE_API NDArray cumsum(int dim=-1) const
OCTAVE_API NDArray sumsq(int dim=-1) const
OCTAVE_API NDArray prod(int dim=-1) const
OCTAVE_API NDArray cumprod(int dim=-1) const
OCTAVE_API boolNDArray all(int dim=-1) const
OCTAVE_API boolNDArray any(int dim=-1) const
OCTAVE_API NDArray sum(int dim=-1) const
octave_idx_type rows(void) const
const Array< octave_idx_type > & col_perm_vec(void) const
void resize(octave_idx_type n, const double &rfv=0)
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
Matrix imag(const ComplexMatrix &a)
Matrix xgemm(const Matrix &a, const Matrix &b, blas_trans_type transa, blas_trans_type transb)
static ComplexMatrix unstack_complex_matrix(const Matrix &sm)
static Matrix stack_complex_matrix(const ComplexMatrix &cm)
Matrix Givens(double x, double y)
static double norm1(const Matrix &a)
Matrix max(double d, const Matrix &m)
std::istream & operator>>(std::istream &is, Matrix &a)
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)
static char get_blas_trans_arg(bool trans)
std::ostream & operator<<(std::ostream &os, const Matrix &a)
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_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 DiagMatrix
class OCTAVE_API ColumnVector
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)
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)
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)