26#if defined (HAVE_CONFIG_H)
105 elem (ia(i), i) = 1.0;
119 elem (i, j) =
static_cast<unsigned char> (a.
elem (i, j));
134 return !(*
this == a);
167 if (r < 0 || r >=
rows () || c < 0 || c + a_len >
cols ())
168 (*current_liboctave_error_handler) (
"range error for insert");
187 if (r < 0 || r + a_len >
rows () || c < 0 || c >=
cols ())
188 (*current_liboctave_error_handler) (
"range error for insert");
208 if (r < 0 || r + a_nr >
rows () || c < 0 || c + a_nc >
cols ())
209 (*current_liboctave_error_handler) (
"range error for insert");
211 fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1);
232 if (nr > 0 && nc > 0)
251 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0
252 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc)
253 (*current_liboctave_error_handler) (
"range error for fill");
255 if (r1 > r2) { std::swap (r1, r2); }
256 if (c1 > c2) { std::swap (c1, c2); }
258 if (r2 >= r1 && c2 >= c1)
276 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
280 retval.
insert (*
this, 0, 0);
281 retval.
insert (a, 0, nc_insert);
291 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
295 retval.
insert (*
this, 0, 0);
296 retval.
insert (a, 0, nc_insert);
305 if (nr != a.
numel ())
306 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
310 retval.
insert (*
this, 0, 0);
311 retval.
insert (a, 0, nc_insert);
321 (*current_liboctave_error_handler) (
"row dimension mismatch for append");
325 retval.
insert (*
this, 0, 0);
326 retval.
insert (a, 0, nc_insert);
336 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
340 retval.
insert (*
this, 0, 0);
341 retval.
insert (a, nr_insert, 0);
350 if (nc != a.
numel ())
351 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
355 retval.
insert (*
this, 0, 0);
356 retval.
insert (a, nr_insert, 0);
366 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
370 retval.
insert (*
this, 0, 0);
371 retval.
insert (a, nr_insert, 0);
381 (*current_liboctave_error_handler) (
"column dimension mismatch for stack");
385 retval.
insert (*
this, 0, 0);
386 retval.
insert (a, nr_insert, 0);
406 if (r1 > r2) { std::swap (r1, r2); }
407 if (c1 > c2) { std::swap (c1, c2); }
443 float sum = colsum.
xelem (i);
462 return inverse (mattype, info, rcon, 0, 0);
470 return inverse (mattype, info, rcon, 0, 0);
475 bool calc_cond)
const
478 return inverse (mattype, info, rcon, force, calc_cond);
486 return inverse (mattype, info, rcon, 0, 0);
493 return inverse (mattype, info, rcon, 0, 0);
498 bool force,
bool calc_cond)
const
505 if (nr != nc || nr == 0 || nc == 0)
506 (*current_liboctave_error_handler) (
"inverse requires square matrix");
508 int typ = mattype.
type ();
516 F77_XFCN (strtri, STRTRI, (F77_CONST_CHAR_ARG2 (&uplo, 1),
517 F77_CONST_CHAR_ARG2 (&udiag, 1),
518 nr, tmp_data, nr, tmp_info
520 F77_CHAR_ARG_LEN (1)));
536 F77_XFCN (strcon, STRCON, (F77_CONST_CHAR_ARG2 (&job, 1),
537 F77_CONST_CHAR_ARG2 (&uplo, 1),
538 F77_CONST_CHAR_ARG2 (&udiag, 1),
539 nr, tmp_data, nr, rcon,
540 work, iwork, dtrcon_info
543 F77_CHAR_ARG_LEN (1)));
545 if (dtrcon_info != 0)
549 if (info == -1 && ! force)
557 bool force,
bool calc_cond)
const
564 if (nr != nc || nr == 0 || nc == 0)
565 (*current_liboctave_error_handler) (
"inverse requires square matrix");
568 F77_INT *pipvt = ipvt.fortran_vec ();
579 F77_XFCN (sgetri, SGETRI, (nc, tmp_data, nr, pipvt,
582 lwork =
static_cast<F77_INT> (z(0));
583 lwork = (lwork < 4 * nc ? 4 * nc : lwork);
593 anorm =
norm1 (retval);
595 F77_XFCN (sgetrf, SGETRF, (nc, nc, tmp_data, nr, pipvt, tmp_info));
611 F77_XFCN (sgecon, SGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
612 nc, tmp_data, nr, anorm,
613 rcon, pz, piz, sgecon_info
614 F77_CHAR_ARG_LEN (1)));
616 if (sgecon_info != 0)
620 if (info == -1 && ! force)
626 F77_XFCN (sgetri, SGETRI, (nc, tmp_data, nr, pipvt,
627 pz, lwork, dgetri_info));
629 if (dgetri_info != 0)
641 bool force,
bool calc_cond)
const
643 int typ = mattype.
type (
false);
647 typ = mattype.
type (*
this);
664 ret =
tinverse (mattype, info, rcon, force, calc_cond);
673 rcon =
chol.rcond ();
676 ret =
chol.inverse ();
683 ret =
finverse (mattype, info, rcon, force, calc_cond);
685 if ((calc_cond || mattype.
ishermitian ()) && rcon == 0.0)
712 * std::numeric_limits<float>::epsilon ();
718 while (r >= 0 && sigma.
elem (r) < tol)
732#if defined (HAVE_FFTW)
737 std::size_t nr =
rows ();
738 std::size_t nc =
cols ();
742 std::size_t npts, nsamples;
744 if (nr == 1 || nc == 1)
746 npts = (nr > nc ? nr : nc);
755 const float *in (
data ());
766 std::size_t nr =
rows ();
767 std::size_t nc =
cols ();
771 std::size_t npts, nsamples;
773 if (nr == 1 || nc == 1)
775 npts = (nr > nc ? nr : nc);
798 const float *in =
data ();
823 (*current_liboctave_error_handler)
824 (
"support for FFTW was unavailable or disabled when liboctave was built");
832 (*current_liboctave_error_handler)
833 (
"support for FFTW was unavailable or disabled when liboctave was built");
841 (*current_liboctave_error_handler)
842 (
"support for FFTW was unavailable or disabled when liboctave was built");
850 (*current_liboctave_error_handler)
851 (
"support for FFTW was unavailable or disabled when liboctave was built");
875 bool calc_cond)
const
878 return determinant (mattype, info, rcon, calc_cond);
884 bool calc_cond)
const
895 (*current_liboctave_error_handler) (
"matrix must be square");
897 volatile int typ = mattype.
type ();
904 typ = mattype.
type (*
this);
910 for (
F77_INT i = 0; i < nc; i++)
911 retval *=
elem (i, i);
921 anorm =
norm1 (*
this);
926 F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
927 tmp_data, nr, tmp_info
928 F77_CHAR_ARG_LEN (1)));
947 F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
948 nr, tmp_data, nr, anorm,
949 rcon, pz, piz, tmp_info
950 F77_CHAR_ARG_LEN (1)));
958 for (
F77_INT i = 0; i < nc; i++)
959 retval *= atmp(i, i);
961 retval = retval.
square ();
965 (*current_liboctave_error_handler) (
"det: invalid dense matrix type");
981 anorm =
norm1 (*
this);
983 F77_XFCN (sgetrf, SGETRF, (nr, nr, tmp_data, nr, pipvt, tmp_info));
1005 F77_XFCN (sgecon, SGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1006 nc, tmp_data, nr, anorm,
1007 rcon, pz, piz, tmp_info
1008 F77_CHAR_ARG_LEN (1)));
1020 for (
F77_INT i = 0; i < nc; i++)
1022 float c = atmp(i, i);
1023 retval *= (ipvt(i) != (i+1)) ? -c : c;
1036 return rcond (mattype);
1047 (*current_liboctave_error_handler) (
"matrix must be square");
1049 if (nr == 0 || nc == 0)
1053 volatile int typ = mattype.
type ();
1056 typ = mattype.
type (*
this);
1061 const float *tmp_data =
data ();
1072 F77_XFCN (strcon, STRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1073 F77_CONST_CHAR_ARG2 (&uplo, 1),
1074 F77_CONST_CHAR_ARG2 (&dia, 1),
1075 nr, tmp_data, nr, rcon,
1077 F77_CHAR_ARG_LEN (1)
1078 F77_CHAR_ARG_LEN (1)
1079 F77_CHAR_ARG_LEN (1)));
1085 (*current_liboctave_error_handler)
1086 (
"permuted triangular matrix not implemented");
1089 const float *tmp_data =
data ();
1100 F77_XFCN (strcon, STRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1101 F77_CONST_CHAR_ARG2 (&uplo, 1),
1102 F77_CONST_CHAR_ARG2 (&dia, 1),
1103 nr, tmp_data, nr, rcon,
1105 F77_CHAR_ARG_LEN (1)
1106 F77_CHAR_ARG_LEN (1)
1107 F77_CHAR_ARG_LEN (1)));
1113 (*current_liboctave_error_handler)
1114 (
"permuted triangular matrix not implemented");
1127 anorm =
norm1 (atmp);
1129 F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1131 F77_CHAR_ARG_LEN (1)));
1146 F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1147 nr, tmp_data, nr, anorm,
1149 F77_CHAR_ARG_LEN (1)));
1167 anorm =
norm1 (atmp);
1174 F77_XFCN (sgetrf, SGETRF, (nr, nr, tmp_data, nr, pipvt, info));
1184 F77_XFCN (sgecon, SGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1185 nc, tmp_data, nr, anorm,
1187 F77_CHAR_ARG_LEN (1)));
1204 float& rcon, solve_singularity_handler sing_handler,
1216 (*current_liboctave_error_handler)
1217 (
"matrix dimension mismatch solution of linear equations");
1219 if (nr == 0 || nc == 0 || b_nc == 0)
1223 volatile int typ = mattype.
type ();
1231 (*current_liboctave_error_handler)
1232 (
"permuted triangular matrix not implemented");
1235 const float *tmp_data =
data ();
1246 F77_XFCN (strtrs, STRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1247 F77_CONST_CHAR_ARG2 (&trans, 1),
1248 F77_CONST_CHAR_ARG2 (&dia, 1),
1249 nr, b_nc, tmp_data, nr,
1250 result, nr, tmp_info
1251 F77_CHAR_ARG_LEN (1)
1252 F77_CHAR_ARG_LEN (1)
1253 F77_CHAR_ARG_LEN (1)));
1268 F77_XFCN (strcon, STRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1269 F77_CONST_CHAR_ARG2 (&uplo, 1),
1270 F77_CONST_CHAR_ARG2 (&dia, 1),
1271 nr, tmp_data, nr, rcon,
1273 F77_CHAR_ARG_LEN (1)
1274 F77_CHAR_ARG_LEN (1)
1275 F77_CHAR_ARG_LEN (1)));
1282 volatile float rcond_plus_one = rcon + 1.0;
1289 sing_handler (rcon);
1307 float& rcon, solve_singularity_handler sing_handler,
1319 (*current_liboctave_error_handler)
1320 (
"matrix dimension mismatch solution of linear equations");
1322 if (nr == 0 || nc == 0 || b_nc == 0)
1326 volatile int typ = mattype.
type ();
1334 (*current_liboctave_error_handler)
1335 (
"permuted triangular matrix not implemented");
1338 const float *tmp_data =
data ();
1349 F77_XFCN (strtrs, STRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1350 F77_CONST_CHAR_ARG2 (&trans, 1),
1351 F77_CONST_CHAR_ARG2 (&dia, 1),
1352 nr, b_nc, tmp_data, nr,
1353 result, nr, tmp_info
1354 F77_CHAR_ARG_LEN (1)
1355 F77_CHAR_ARG_LEN (1)
1356 F77_CHAR_ARG_LEN (1)));
1371 F77_XFCN (strcon, STRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1372 F77_CONST_CHAR_ARG2 (&uplo, 1),
1373 F77_CONST_CHAR_ARG2 (&dia, 1),
1374 nr, tmp_data, nr, rcon,
1376 F77_CHAR_ARG_LEN (1)
1377 F77_CHAR_ARG_LEN (1)
1378 F77_CHAR_ARG_LEN (1)));
1385 volatile float rcond_plus_one = rcon + 1.0;
1392 sing_handler (rcon);
1409 float& rcon, solve_singularity_handler sing_handler,
1410 bool calc_cond)
const
1420 if (nr != nc || nr != b_nr)
1421 (*current_liboctave_error_handler)
1422 (
"matrix dimension mismatch solution of linear equations");
1424 if (nr == 0 || b_nc == 0)
1428 volatile int typ = mattype.
type ();
1443 anorm =
norm1 (atmp);
1447 F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1448 tmp_data, nr, tmp_info
1449 F77_CHAR_ARG_LEN (1)));
1471 F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1472 nr, tmp_data, nr, anorm,
1473 rcon, pz, piz, tmp_info
1474 F77_CHAR_ARG_LEN (1)));
1481 volatile float rcond_plus_one = rcon + 1.0;
1488 sing_handler (rcon);
1499 F77_XFCN (spotrs, SPOTRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1500 nr, b_nc, tmp_data, nr,
1501 result, b_nr, tmp_info
1502 F77_CHAR_ARG_LEN (1)));
1524 if (calc_cond && anorm < 0.0)
1525 anorm =
norm1 (atmp);
1534 F77_XFCN (sgetrf, SGETRF, (nr, nr, tmp_data, nr, pipvt, tmp_info));
1545 sing_handler (rcon);
1557 F77_XFCN (sgecon, SGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1558 nc, tmp_data, nr, anorm,
1559 rcon, pz, piz, tmp_info
1560 F77_CHAR_ARG_LEN (1)));
1567 volatile float rcond_plus_one = rcon + 1.0;
1572 sing_handler (rcon);
1584 F77_XFCN (sgetrs, SGETRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1585 nr, b_nc, tmp_data, nr,
1586 pipvt, result, b_nr, tmp_info
1587 F77_CHAR_ARG_LEN (1)));
1596 (*current_liboctave_error_handler) (
"incorrect matrix type");
1607 return solve (mattype, b, info, rcon,
nullptr);
1615 return solve (mattype, b, info, rcon,
nullptr);
1622 return solve (mattype, b, info, rcon,
nullptr);
1628 float& rcon, solve_singularity_handler sing_handler,
1632 int typ = mattype.
type ();
1635 typ = mattype.
type (*
this);
1639 retval =
utsolve (mattype, b, info, rcon, sing_handler,
true, transt);
1641 retval =
ltsolve (mattype, b, info, rcon, sing_handler,
true, transt);
1646 retval =
fsolve (mattype, b, info, rcon, sing_handler,
true);
1648 (*current_liboctave_error_handler) (
"unknown matrix type");
1654 retval =
lssolve (b, info, rank, rcon);
1665 return solve (mattype, b, info, rcon,
nullptr);
1673 return solve (mattype, b, info, rcon,
nullptr);
1681 return solve (mattype, b, info, rcon,
nullptr);
1708 const float *smd = sm.
data ();
1718 float& rcon, solve_singularity_handler sing_handler,
1722 tmp =
solve (mattype, tmp, info, rcon, sing_handler, singular_fallback,
1732 return solve (mattype, b, info, rcon);
1740 return solve (mattype, b, info, rcon);
1748 return solve (mattype, b, info, rcon,
nullptr);
1754 float& rcon, solve_singularity_handler sing_handler,
1758 tmp =
solve (mattype, tmp, info, rcon, sing_handler,
true, transt);
1767 return tmp.
solve (mattype, b);
1775 return tmp.
solve (mattype, b, info);
1783 return tmp.
solve (mattype, b, info, rcon);
1789 solve_singularity_handler sing_handler,
1793 return tmp.
solve (mattype, b, info, rcon, sing_handler, transt);
1801 return solve (b, info, rcon,
nullptr);
1808 return solve (b, info, rcon,
nullptr);
1815 return solve (b, info, rcon,
nullptr);
1820 float& rcon, solve_singularity_handler sing_handler,
1824 return solve (mattype, b, info, rcon, sing_handler,
true, transt);
1831 return tmp.
solve (b);
1838 return tmp.
solve (b, info);
1846 return tmp.
solve (b, info, rcon);
1852 solve_singularity_handler sing_handler,
1856 return tmp.
solve (b, info, rcon, sing_handler, transt);
1863 return solve (b, info, rcon);
1870 return solve (b, info, rcon);
1877 return solve (b, info, rcon,
nullptr);
1882 float& rcon, solve_singularity_handler sing_handler,
1886 return solve (mattype, b, info, rcon, sing_handler, transt);
1893 return tmp.
solve (b);
1901 return tmp.
solve (b, info);
1909 return tmp.
solve (b, info, rcon);
1914 float& rcon, solve_singularity_handler sing_handler,
1918 return tmp.
solve (b, info, rcon, sing_handler, transt);
1927 return lssolve (b, info, rank, rcon);
1935 return lssolve (b, info, rank, rcon);
1943 return lssolve (b, info, rank, rcon);
1961 (*current_liboctave_error_handler)
1962 (
"matrix dimension mismatch solution of linear equations");
1964 if (m == 0 || n == 0 || b_nc == 0)
1968 volatile F77_INT minmn = (m < n ? m : n);
1969 F77_INT maxmn = (m > n ? m : n);
1975 for (
F77_INT j = 0; j < nrhs; j++)
1976 for (
F77_INT i = 0; i < m; i++)
1977 retval.
elem (i, j) = b.
elem (i, j);
1996 F77_CONST_CHAR_ARG2 (
" ", 1),
1998 F77_CHAR_ARG_LEN (6)
1999 F77_CHAR_ARG_LEN (1));
2003 F77_CONST_CHAR_ARG2 (
" ", 1),
2004 m, n, nrhs, -1, mnthr
2005 F77_CHAR_ARG_LEN (6)
2006 F77_CHAR_ARG_LEN (1));
2010 float dminmn =
static_cast<float> (minmn);
2011 float dsmlsizp1 =
static_cast<float> (smlsiz+1);
2018 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2027 F77_XFCN (sgelsd, SGELSD, (m, n, nrhs, tmp_data, m, pretval, maxmn,
2029 lwork, piwork, tmp_info));
2038 if (n > m && n >= mnthr)
2041 = 9*m + 2*m*smlsiz + 8*m*nlvl + m*nrhs + (smlsiz+1)*(smlsiz+1);
2054 if (wlalsd > addend)
2057 const F77_INT lworkaround = 4*m + m*m + addend;
2059 if (work(0) < lworkaround)
2060 work(0) = lworkaround;
2065 = 12*n + 2*n*smlsiz + 8*n*nlvl + n*nrhs + (smlsiz+1)*(smlsiz+1);
2067 if (work(0) < lworkaround)
2068 work(0) = lworkaround;
2071 lwork =
static_cast<F77_INT> (work(0));
2074 float anorm =
norm1 (*
this);
2089 F77_XFCN (sgelsd, SGELSD, (m, n, nrhs, tmp_data, m, pretval,
2090 maxmn, ps, rcon, tmp_rank,
2097 if (s.
elem (0) == 0.0)
2100 rcon = s.
elem (minmn - 1) / s.
elem (0);
2116 return tmp.
lssolve (b, info, rank, rcon);
2125 return tmp.
lssolve (b, info, rank, rcon);
2134 return tmp.
lssolve (b, info, rank, rcon);
2142 return tmp.
lssolve (b, info, rank, rcon);
2151 return lssolve (b, info, rank, rcon);
2159 return lssolve (b, info, rank, rcon);
2167 return lssolve (b, info, rank, rcon);
2181 if (m != b.
numel ())
2182 (*current_liboctave_error_handler)
2183 (
"matrix dimension mismatch solution of linear equations");
2185 if (m == 0 || n == 0)
2189 volatile F77_INT minmn = (m < n ? m : n);
2190 F77_INT maxmn = (m > n ? m : n);
2197 for (
F77_INT i = 0; i < m; i++)
2217 F77_CONST_CHAR_ARG2 (
" ", 1),
2219 F77_CHAR_ARG_LEN (6)
2220 F77_CHAR_ARG_LEN (1));
2224 float dminmn =
static_cast<float> (minmn);
2225 float dsmlsizp1 =
static_cast<float> (smlsiz+1);
2232 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2241 F77_XFCN (sgelsd, SGELSD, (m, n, nrhs, tmp_data, m, pretval, maxmn,
2243 lwork, piwork, tmp_info));
2248 lwork =
static_cast<F77_INT> (work(0));
2251 F77_XFCN (sgelsd, SGELSD, (m, n, nrhs, tmp_data, m, pretval,
2252 maxmn, ps, rcon, tmp_rank,
2261 if (s.
elem (0) == 0.0)
2264 rcon = s.
elem (minmn - 1) / s.
elem (0);
2280 return tmp.
lssolve (b, info, rank, rcon);
2290 return tmp.
lssolve (b, info, rank, rcon);
2299 return tmp.
lssolve (b, info, rank, rcon);
2307 return tmp.
lssolve (b, info, rank, rcon);
2319 if (nr != a_nr || nc != a_nc)
2337 if (nr != a_nr || nc != a_nc)
2362 F77_XFCN (sgemm, SGEMM, (F77_CONST_CHAR_ARG2 (
"N", 1),
2363 F77_CONST_CHAR_ARG2 (
"N", 1),
2366 F77_CHAR_ARG_LEN (1)
2367 F77_CHAR_ARG_LEN (1)));
2425 if (nr == 1 || nc == 1)
2448 if (nr > 0 && nc > 0)
2459 for (idx_j = 0; idx_j < nc; idx_j++)
2461 tmp_min =
elem (i, idx_j);
2469 float tmp =
elem (i, j);
2473 else if (tmp < tmp_min)
2480 result.
elem (i) = tmp_min;
2503 if (nr > 0 && nc > 0)
2514 for (idx_j = 0; idx_j < nc; idx_j++)
2516 tmp_max =
elem (i, idx_j);
2524 float tmp =
elem (i, j);
2528 else if (tmp > tmp_max)
2535 result.
elem (i) = tmp_max;
2558 if (nr > 0 && nc > 0)
2569 for (idx_i = 0; idx_i < nr; idx_i++)
2571 tmp_min =
elem (idx_i, j);
2579 float tmp =
elem (i, j);
2583 else if (tmp < tmp_min)
2590 result.
elem (j) = tmp_min;
2613 if (nr > 0 && nc > 0)
2624 for (idx_i = 0; idx_i < nr; idx_i++)
2626 tmp_max =
elem (idx_i, j);
2634 float tmp =
elem (i, j);
2638 else if (tmp > tmp_max)
2645 result.
elem (j) = tmp_max;
2661 octave::write_value<float> (os, a.
elem (i, j));
2674 if (nr > 0 && nc > 0)
2680 tmp = octave::read_value<float> (is);
2682 a.
elem (i, j) = tmp;
2694 float cc, s, temp_r;
2696 F77_FUNC (slartg, SLARTG) (
x, y, cc, s, temp_r);
2743 F77_XFCN (strsyl, STRSYL, (F77_CONST_CHAR_ARG2 (
"N", 1),
2744 F77_CONST_CHAR_ARG2 (
"N", 1),
2745 1, a_nr, b_nr, pa, a_nr, pb,
2746 b_nr, px, a_nr,
scale, info
2747 F77_CHAR_ARG_LEN (1)
2748 F77_CHAR_ARG_LEN (1)));
2781 return trans ?
'T' :
'N';
2804 if (a_nr == 0 || a_nc == 0 || b_nc == 0)
2806 else if (a.
data () == b.
data () && a_nr == b_nc && tra != trb)
2814 F77_XFCN (ssyrk, SSYRK, (F77_CONST_CHAR_ARG2 (
"U", 1),
2815 F77_CONST_CHAR_ARG2 (&ctra, 1),
2817 a.
data (), lda, 0.0, c, a_nr
2818 F77_CHAR_ARG_LEN (1)
2819 F77_CHAR_ARG_LEN (1)));
2820 for (
int j = 0; j < a_nr; j++)
2821 for (
int i = 0; i < j; i++)
2842 F77_XFCN (sgemv, SGEMV, (F77_CONST_CHAR_ARG2 (&ctra, 1),
2843 lda, tda, 1.0, a.
data (), lda,
2844 b.
data (), 1, 0.0, c, 1
2845 F77_CHAR_ARG_LEN (1)));
2851 F77_XFCN (sgemv, SGEMV, (F77_CONST_CHAR_ARG2 (&crevtrb, 1),
2852 ldb, tdb, 1.0, b.
data (), ldb,
2853 a.
data (), 1, 0.0, c, 1
2854 F77_CHAR_ARG_LEN (1)));
2860 F77_XFCN (sgemm, SGEMM, (F77_CONST_CHAR_ARG2 (&ctra, 1),
2861 F77_CONST_CHAR_ARG2 (&ctrb, 1),
2862 a_nr, b_nc, a_nc, 1.0, a.
data (),
2863 lda, b.
data (), ldb, 0.0, c, a_nr
2864 F77_CHAR_ARG_LEN (1)
2865 F77_CHAR_ARG_LEN (1)));
2875 return xgemm (a, b);
2880#define EMPTY_RETURN_CHECK(T) \
2881 if (nr == 0 || nc == 0) \
2931 (*current_liboctave_error_handler)
2932 (
"two-arg min requires same size arguments");
2995 (*current_liboctave_error_handler)
2996 (
"two-arg max requires same size arguments");
3019 if (x2.
numel () != m)
3020 (*current_liboctave_error_handler)
3021 (
"linspace: vectors must be of equal length");
3027 retval.
clear (m, 0);
3031 retval.clear (m, n);
3033 retval.xelem (i, 0) = x1(i);
3036 float *delta = &retval.xelem (0, n-1);
3038 delta[i] = (x1(i) == x2(i)) ? 0 : (x2(i) - x1(i)) / (n - 1);
3042 retval.xelem (i, j) = x1(i) + j*delta[i];
3045 retval.xelem (i, n-1) = x2(i);
base_det< float > FloatDET
bool issquare(void) const
float & xelem(octave_idx_type n)
OCTARRAY_API void clear(void)
OCTARRAY_API Array< float, 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
float & elem(octave_idx_type n)
octave_idx_type rows(void) const
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type columns(void) const
const float * 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
void resize(octave_idx_type n, const float &rfv=0)
OCTAVE_API FloatColumnVector extract(octave_idx_type r1, octave_idx_type r2) const
OCTAVE_API FloatComplexMatrix lssolve(const FloatMatrix &b) const
OCTAVE_API FloatComplexMatrix solve(MatrixType &mattype, const FloatMatrix &b) const
FloatColumnVector extract_diag(octave_idx_type k=0) const
OCTAVE_API float rcond(void) const
OCTAVE_API FloatDET determinant(void) const
FloatMatrix fsolve(MatrixType &mattype, const FloatMatrix &b, octave_idx_type &info, float &rcon, solve_singularity_handler sing_handler, bool calc_cond=false) const
OCTAVE_API FloatComplexMatrix ifourier(void) const
OCTAVE_API FloatComplexMatrix ifourier2d(void) const
OCTAVE_API bool issymmetric(void) const
OCTAVE_API FloatMatrix abs(void) const
FloatMatrix transpose(void) const
OCTAVE_API FloatMatrix sumsq(int dim=-1) const
OCTAVE_API FloatMatrix sum(int dim=-1) const
OCTAVE_API bool operator==(const FloatMatrix &a) const
void resize(octave_idx_type nr, octave_idx_type nc, float rfv=0)
OCTAVE_API FloatMatrix lssolve(const FloatMatrix &b) const
FloatMatrix utsolve(MatrixType &mattype, const FloatMatrix &b, octave_idx_type &info, float &rcon, solve_singularity_handler sing_handler, bool calc_cond=false, blas_trans_type transt=blas_no_trans) const
friend class FloatComplexMatrix
OCTAVE_API FloatMatrix & fill(float val)
OCTAVE_API FloatColumnVector row_max(void) const
FloatMatrix(void)=default
OCTAVE_API FloatComplexMatrix fourier2d(void) const
OCTAVE_API FloatMatrix prod(int dim=-1) const
OCTAVE_API FloatMatrix & insert(const FloatMatrix &a, octave_idx_type r, octave_idx_type c)
OCTAVE_API FloatRowVector row(octave_idx_type i) const
OCTAVE_API FloatColumnVector row_min(void) const
OCTAVE_API FloatMatrix & operator-=(const FloatDiagMatrix &a)
FloatMatrix ltsolve(MatrixType &mattype, const FloatMatrix &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 FloatMatrix & operator+=(const FloatDiagMatrix &a)
OCTAVE_API FloatMatrix inverse(void) const
OCTAVE_API FloatRowVector column_max(void) const
FloatMatrix tinverse(MatrixType &mattype, octave_idx_type &info, float &rcon, bool force, bool calc_cond) const
OCTAVE_API FloatRowVector column_min(void) const
OCTAVE_API FloatMatrix solve(MatrixType &mattype, const FloatMatrix &b) const
OCTAVE_API FloatMatrix cumsum(int dim=-1) const
OCTAVE_API FloatMatrix append(const FloatMatrix &a) const
OCTAVE_API FloatMatrix diag(octave_idx_type k=0) const
OCTAVE_API bool operator!=(const FloatMatrix &a) const
FloatMatrix finverse(MatrixType &mattype, octave_idx_type &info, float &rcon, bool force, bool calc_cond) const
OCTAVE_API FloatMatrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
OCTAVE_API FloatMatrix cumprod(int dim=-1) const
OCTAVE_API FloatMatrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
OCTAVE_API FloatComplexMatrix fourier(void) const
OCTAVE_API FloatColumnVector column(octave_idx_type i) const
OCTAVE_API FloatMatrix stack(const FloatMatrix &a) const
OCTAVE_API FloatMatrix pseudo_inverse(float tol=0.0) const
OCTAVE_API FloatNDArray sum(int dim=-1) const
OCTAVE_API FloatNDArray prod(int dim=-1) const
OCTAVE_API FloatNDArray cumprod(int dim=-1) const
OCTAVE_API FloatNDArray & insert(const FloatNDArray &a, octave_idx_type r, octave_idx_type c)
OCTAVE_API FloatNDArray cumsum(int dim=-1) const
OCTAVE_API FloatNDArray sumsq(int dim=-1) const
OCTAVE_API FloatNDArray abs(void) const
OCTAVE_API FloatNDArray diag(octave_idx_type k=0) const
void resize(octave_idx_type n, const float &rfv=0)
bool ishermitian(void) const
void mark_as_rectangular(void)
OCTAVE_API void mark_as_unsymmetric(void)
OCTAVE_API int type(bool quiet=true)
octave_idx_type rows(void) const
const Array< octave_idx_type > & col_perm_vec(void) const
Vector representing the dimensions (size) of an Array.
static int ifft(const Complex *in, Complex *out, std::size_t npts, std::size_t nsamples=1, octave_idx_type stride=1, octave_idx_type dist=-1)
static int fftNd(const double *, Complex *, const int, const dim_vector &)
static int ifftNd(const Complex *, Complex *, const int, const dim_vector &)
static int fft(const double *in, Complex *out, std::size_t npts, std::size_t nsamples=1, octave_idx_type stride=1, octave_idx_type dist=-1)
static const idx_vector colon
T unitary_schur_matrix(void) const
T schur_matrix(void) const
DM_T singular_values(void) const
T right_singular_matrix(void) const
T left_singular_matrix(void) const
#define F77_XFCN(f, F, args)
octave_f77_int_type F77_INT
FloatMatrix operator*(const FloatColumnVector &v, const FloatRowVector &a)
static FloatComplexMatrix unstack_complex_matrix(const FloatMatrix &sm)
static FloatMatrix stack_complex_matrix(const FloatComplexMatrix &cm)
FloatMatrix linspace(const FloatColumnVector &x1, const FloatColumnVector &x2, octave_idx_type n)
FloatMatrix min(float d, const FloatMatrix &m)
#define EMPTY_RETURN_CHECK(T)
FloatMatrix real(const FloatComplexMatrix &a)
FloatMatrix imag(const FloatComplexMatrix &a)
static char get_blas_trans_arg(bool trans)
FloatMatrix max(float d, const FloatMatrix &m)
std::ostream & operator<<(std::ostream &os, const FloatMatrix &a)
static float norm1(const FloatMatrix &a)
FloatMatrix Givens(float x, float y)
FloatMatrix Sylvester(const FloatMatrix &a, const FloatMatrix &b, const FloatMatrix &c)
FloatMatrix xgemm(const FloatMatrix &a, const FloatMatrix &b, blas_trans_type transa, blas_trans_type transb)
std::istream & operator>>(std::istream &is, FloatMatrix &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 FloatColumnVector
class OCTAVE_API FloatMatrix
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< float > FloatComplex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
static bool scalar(const dim_vector &dims)
F77_RET_T F77_FUNC(xerbla, XERBLA)(F77_CONST_CHAR_ARG_DEF(s_arg
subroutine xilaenv(ispec, name, opts, n1, n2, n3, n4, retval)
subroutine xsdot(n, dx, incx, dy, incy, retval)