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,
580 z.fortran_vec (), lwork, tmp_info));
582 lwork =
static_cast<F77_INT> (z(0));
583 lwork = (lwork < 4 * nc ? 4 * nc : lwork);
585 float *pz = z.fortran_vec ();
593 anorm = norm1 (retval);
595 F77_XFCN (sgetrf, SGETRF, (nc, nc, tmp_data, nr, pipvt, tmp_info));
614 F77_INT *piz = iz.fortran_vec ();
615 F77_XFCN (sgecon, SGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
616 nc, tmp_data, nr, anorm,
617 rcon, pz, piz, sgecon_info
618 F77_CHAR_ARG_LEN (1)));
620 if (sgecon_info != 0)
625 if (info == -1 && ! force)
631 F77_XFCN (sgetri, SGETRI, (nc, tmp_data, nr, pipvt,
632 pz, lwork, dgetri_info));
634 if (dgetri_info != 0)
646 bool force,
bool calc_cond)
const
648 int typ = mattype.
type (
false);
652 typ = mattype.
type (*
this);
659 float scalar = this->
elem (0);
669 ret = tinverse (mattype, info, rcon, force, calc_cond);
674 octave::math::chol<FloatMatrix>
chol (*
this, info,
true, calc_cond);
688 ret = finverse (mattype, info, rcon, force, calc_cond);
690 if ((calc_cond || mattype.
ishermitian ()) && rcon == 0.0)
701 octave::math::svd<FloatMatrix> result (*
this,
702 octave::math::svd<FloatMatrix>::Type::economy);
717 * std::numeric_limits<float>::epsilon ();
723 while (
r >= 0 && sigma.
elem (
r) < tol)
737 #if defined (HAVE_FFTW)
742 std::size_t nr =
rows ();
743 std::size_t nc =
cols ();
747 std::size_t npts, nsamples;
749 if (nr == 1 || nc == 1)
751 npts = (nr > nc ? nr : nc);
760 const float *in (
data ());
763 octave::fftw::fft (in, out, npts, nsamples);
771 std::size_t nr =
rows ();
772 std::size_t nc =
cols ();
776 std::size_t npts, nsamples;
778 if (nr == 1 || nc == 1)
780 npts = (nr > nc ? nr : nc);
793 octave::fftw::ifft (in, out, npts, nsamples);
803 const float *in =
data ();
805 octave::fftw::fftNd (in, retval.
fortran_vec (), 2, dv);
818 octave::fftw::ifftNd (out, out, 2, dv);
828 (*current_liboctave_error_handler)
829 (
"support for FFTW was unavailable or disabled when liboctave was built");
837 (*current_liboctave_error_handler)
838 (
"support for FFTW was unavailable or disabled when liboctave was built");
846 (*current_liboctave_error_handler)
847 (
"support for FFTW was unavailable or disabled when liboctave was built");
855 (*current_liboctave_error_handler)
856 (
"support for FFTW was unavailable or disabled when liboctave was built");
880 bool calc_cond)
const
883 return determinant (mattype, info, rcon, calc_cond);
889 bool calc_cond)
const
900 (*current_liboctave_error_handler) (
"matrix must be square");
902 volatile int typ = mattype.
type ();
909 typ = mattype.
type (*
this);
915 for (
F77_INT i = 0; i < nc; i++)
916 retval *=
elem (i, i);
926 anorm = norm1 (*
this);
931 F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
932 tmp_data, nr, tmp_info
933 F77_CHAR_ARG_LEN (1)));
952 F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
953 nr, tmp_data, nr, anorm,
954 rcon, pz, piz, tmp_info
955 F77_CHAR_ARG_LEN (1)));
963 for (
F77_INT i = 0; i < nc; i++)
964 retval *= atmp(i, i);
966 retval = retval.
square ();
970 (*current_liboctave_error_handler) (
"det: invalid dense matrix type");
986 anorm = norm1 (*
this);
988 F77_XFCN (sgetrf, SGETRF, (nr, nr, tmp_data, nr, pipvt, tmp_info));
1010 F77_XFCN (sgecon, SGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1011 nc, tmp_data, nr, anorm,
1012 rcon, pz, piz, tmp_info
1013 F77_CHAR_ARG_LEN (1)));
1025 for (
F77_INT i = 0; i < nc; i++)
1027 float c = atmp(i, i);
1028 retval *= (ipvt(i) != (i+1)) ? -c : c;
1041 return rcond (mattype);
1052 (*current_liboctave_error_handler) (
"matrix must be square");
1054 if (nr == 0 || nc == 0)
1058 volatile int typ = mattype.
type ();
1061 typ = mattype.
type (*
this);
1066 const float *tmp_data =
data ();
1077 F77_XFCN (strcon, STRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1078 F77_CONST_CHAR_ARG2 (&uplo, 1),
1079 F77_CONST_CHAR_ARG2 (&dia, 1),
1080 nr, tmp_data, nr, rcon,
1082 F77_CHAR_ARG_LEN (1)
1083 F77_CHAR_ARG_LEN (1)
1084 F77_CHAR_ARG_LEN (1)));
1090 (*current_liboctave_error_handler)
1091 (
"permuted triangular matrix not implemented");
1094 const float *tmp_data =
data ();
1105 F77_XFCN (strcon, STRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1106 F77_CONST_CHAR_ARG2 (&uplo, 1),
1107 F77_CONST_CHAR_ARG2 (&dia, 1),
1108 nr, tmp_data, nr, rcon,
1110 F77_CHAR_ARG_LEN (1)
1111 F77_CHAR_ARG_LEN (1)
1112 F77_CHAR_ARG_LEN (1)));
1118 (*current_liboctave_error_handler)
1119 (
"permuted triangular matrix not implemented");
1132 anorm = norm1 (atmp);
1134 F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1136 F77_CHAR_ARG_LEN (1)));
1151 F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1152 nr, tmp_data, nr, anorm,
1154 F77_CHAR_ARG_LEN (1)));
1172 anorm = norm1 (atmp);
1179 F77_XFCN (sgetrf, SGETRF, (nr, nr, tmp_data, nr, pipvt, info));
1189 F77_XFCN (sgecon, SGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1190 nc, tmp_data, nr, anorm,
1192 F77_CHAR_ARG_LEN (1)));
1209 float& rcon, solve_singularity_handler sing_handler,
1221 (*current_liboctave_error_handler)
1222 (
"matrix dimension mismatch solution of linear equations");
1224 if (nr == 0 || nc == 0 || b_nc == 0)
1228 volatile int typ = mattype.
type ();
1236 (*current_liboctave_error_handler)
1237 (
"permuted triangular matrix not implemented");
1240 const float *tmp_data =
data ();
1251 F77_XFCN (strtrs, STRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1252 F77_CONST_CHAR_ARG2 (&trans, 1),
1253 F77_CONST_CHAR_ARG2 (&dia, 1),
1254 nr, b_nc, tmp_data, nr,
1255 result, nr, tmp_info
1256 F77_CHAR_ARG_LEN (1)
1257 F77_CHAR_ARG_LEN (1)
1258 F77_CHAR_ARG_LEN (1)));
1269 float *pz = z.fortran_vec ();
1271 F77_INT *piz = iz.fortran_vec ();
1273 F77_XFCN (strcon, STRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1274 F77_CONST_CHAR_ARG2 (&uplo, 1),
1275 F77_CONST_CHAR_ARG2 (&dia, 1),
1276 nr, tmp_data, nr, rcon,
1278 F77_CHAR_ARG_LEN (1)
1279 F77_CHAR_ARG_LEN (1)
1280 F77_CHAR_ARG_LEN (1)));
1287 volatile float rcond_plus_one = rcon + 1.0;
1294 sing_handler (rcon);
1312 float& rcon, solve_singularity_handler sing_handler,
1324 (*current_liboctave_error_handler)
1325 (
"matrix dimension mismatch solution of linear equations");
1327 if (nr == 0 || nc == 0 || b_nc == 0)
1331 volatile int typ = mattype.
type ();
1339 (*current_liboctave_error_handler)
1340 (
"permuted triangular matrix not implemented");
1343 const float *tmp_data =
data ();
1354 F77_XFCN (strtrs, STRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
1355 F77_CONST_CHAR_ARG2 (&trans, 1),
1356 F77_CONST_CHAR_ARG2 (&dia, 1),
1357 nr, b_nc, tmp_data, nr,
1358 result, nr, tmp_info
1359 F77_CHAR_ARG_LEN (1)
1360 F77_CHAR_ARG_LEN (1)
1361 F77_CHAR_ARG_LEN (1)));
1372 float *pz = z.fortran_vec ();
1374 F77_INT *piz = iz.fortran_vec ();
1376 F77_XFCN (strcon, STRCON, (F77_CONST_CHAR_ARG2 (&
norm, 1),
1377 F77_CONST_CHAR_ARG2 (&uplo, 1),
1378 F77_CONST_CHAR_ARG2 (&dia, 1),
1379 nr, tmp_data, nr, rcon,
1381 F77_CHAR_ARG_LEN (1)
1382 F77_CHAR_ARG_LEN (1)
1383 F77_CHAR_ARG_LEN (1)));
1390 volatile float rcond_plus_one = rcon + 1.0;
1397 sing_handler (rcon);
1414 float& rcon, solve_singularity_handler sing_handler,
1415 bool calc_cond)
const
1425 if (nr != nc || nr != b_nr)
1426 (*current_liboctave_error_handler)
1427 (
"matrix dimension mismatch solution of linear equations");
1429 if (nr == 0 || b_nc == 0)
1433 volatile int typ = mattype.
type ();
1448 anorm = norm1 (atmp);
1452 F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
1453 tmp_data, nr, tmp_info
1454 F77_CHAR_ARG_LEN (1)));
1472 float *pz = z.fortran_vec ();
1474 F77_INT *piz = iz.fortran_vec ();
1476 F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
1477 nr, tmp_data, nr, anorm,
1478 rcon, pz, piz, tmp_info
1479 F77_CHAR_ARG_LEN (1)));
1486 volatile float rcond_plus_one = rcon + 1.0;
1493 sing_handler (rcon);
1504 F77_XFCN (spotrs, SPOTRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1505 nr, b_nc, tmp_data, nr,
1506 result, b_nr, tmp_info
1507 F77_CHAR_ARG_LEN (1)));
1524 F77_INT *pipvt = ipvt.fortran_vec ();
1529 if (calc_cond && anorm < 0.0)
1530 anorm = norm1 (atmp);
1533 float *pz = z.fortran_vec ();
1535 F77_INT *piz = iz.fortran_vec ();
1539 F77_XFCN (sgetrf, SGETRF, (nr, nr, tmp_data, nr, pipvt, tmp_info));
1550 sing_handler (rcon);
1562 F77_XFCN (sgecon, SGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
1563 nc, tmp_data, nr, anorm,
1564 rcon, pz, piz, tmp_info
1565 F77_CHAR_ARG_LEN (1)));
1572 volatile float rcond_plus_one = rcon + 1.0;
1577 sing_handler (rcon);
1589 F77_XFCN (sgetrs, SGETRS, (F77_CONST_CHAR_ARG2 (&job, 1),
1590 nr, b_nc, tmp_data, nr,
1591 pipvt, result, b_nr, tmp_info
1592 F77_CHAR_ARG_LEN (1)));
1601 (*current_liboctave_error_handler) (
"incorrect matrix type");
1612 return solve (mattype, b, info, rcon,
nullptr);
1620 return solve (mattype, b, info, rcon,
nullptr);
1627 return solve (mattype, b, info, rcon,
nullptr);
1633 float& rcon, solve_singularity_handler sing_handler,
1637 int typ = mattype.
type ();
1640 typ = mattype.
type (*
this);
1644 retval = utsolve (mattype, b, info, rcon, sing_handler,
true, transt);
1646 retval = ltsolve (mattype, b, info, rcon, sing_handler,
true, transt);
1651 retval = fsolve (mattype, b, info, rcon, sing_handler,
true);
1653 (*current_liboctave_error_handler) (
"unknown matrix type");
1659 retval =
lssolve (b, info, rank, rcon);
1670 return solve (mattype, b, info, rcon,
nullptr);
1678 return solve (mattype, b, info, rcon,
nullptr);
1686 return solve (mattype, b, info, rcon,
nullptr);
1713 const float *smd = sm.
data ();
1723 float& rcon, solve_singularity_handler sing_handler,
1727 tmp =
solve (mattype, tmp, info, rcon, sing_handler, singular_fallback,
1729 return unstack_complex_matrix (tmp);
1737 return solve (mattype, b, info, rcon);
1745 return solve (mattype, b, info, rcon);
1753 return solve (mattype, b, info, rcon,
nullptr);
1759 float& rcon, solve_singularity_handler sing_handler,
1763 tmp =
solve (mattype, tmp, info, rcon, sing_handler,
true, transt);
1772 return tmp.
solve (mattype, b);
1780 return tmp.
solve (mattype, b, info);
1788 return tmp.
solve (mattype, b, info, rcon);
1794 solve_singularity_handler sing_handler,
1798 return tmp.
solve (mattype, b, info, rcon, sing_handler, transt);
1806 return solve (b, info, rcon,
nullptr);
1813 return solve (b, info, rcon,
nullptr);
1820 return solve (b, info, rcon,
nullptr);
1825 float& rcon, solve_singularity_handler sing_handler,
1829 return solve (mattype, b, info, rcon, sing_handler,
true, transt);
1836 return tmp.
solve (b);
1843 return tmp.
solve (b, info);
1851 return tmp.
solve (b, info, rcon);
1857 solve_singularity_handler sing_handler,
1861 return tmp.
solve (b, info, rcon, sing_handler, transt);
1868 return solve (b, info, rcon);
1875 return solve (b, info, rcon);
1882 return solve (b, info, rcon,
nullptr);
1887 float& rcon, solve_singularity_handler sing_handler,
1891 return solve (mattype, b, info, rcon, sing_handler, transt);
1898 return tmp.
solve (b);
1906 return tmp.
solve (b, info);
1914 return tmp.
solve (b, info, rcon);
1919 float& rcon, solve_singularity_handler sing_handler,
1923 return tmp.
solve (b, info, rcon, sing_handler, transt);
1932 return lssolve (b, info, rank, rcon);
1940 return lssolve (b, info, rank, rcon);
1948 return lssolve (b, info, rank, rcon);
1966 (*current_liboctave_error_handler)
1967 (
"matrix dimension mismatch solution of linear equations");
1969 if (
m == 0 ||
n == 0 || b_nc == 0)
1980 for (
F77_INT j = 0; j < nrhs; j++)
1982 retval.
elem (i, j) = b.
elem (i, j);
2001 F77_CONST_CHAR_ARG2 (
" ", 1),
2003 F77_CHAR_ARG_LEN (6)
2004 F77_CHAR_ARG_LEN (1));
2008 F77_CONST_CHAR_ARG2 (
" ", 1),
2009 m,
n, nrhs, -1, mnthr
2010 F77_CHAR_ARG_LEN (6)
2011 F77_CHAR_ARG_LEN (1));
2015 float dminmn =
static_cast<float> (minmn);
2016 float dsmlsizp1 =
static_cast<float> (smlsiz+1);
2023 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2032 F77_XFCN (sgelsd, SGELSD, (
m,
n, nrhs, tmp_data,
m, pretval, maxmn,
2034 lwork, piwork, tmp_info));
2043 if (
n >
m &&
n >= mnthr)
2046 = 9*
m + 2*
m*smlsiz + 8*
m*nlvl +
m*nrhs + (smlsiz+1)*(smlsiz+1);
2059 if (wlalsd > addend)
2062 const F77_INT lworkaround = 4*
m +
m*
m + addend;
2064 if (work(0) < lworkaround)
2065 work(0) = lworkaround;
2070 = 12*
n + 2*
n*smlsiz + 8*
n*nlvl +
n*nrhs + (smlsiz+1)*(smlsiz+1);
2072 if (work(0) < lworkaround)
2073 work(0) = lworkaround;
2076 lwork =
static_cast<F77_INT> (work(0));
2079 float anorm = norm1 (*
this);
2094 F77_XFCN (sgelsd, SGELSD, (
m,
n, nrhs, tmp_data,
m, pretval,
2095 maxmn, ps, rcon, tmp_rank,
2102 if (s.
elem (0) == 0.0)
2105 rcon = s.
elem (minmn - 1) / s.
elem (0);
2121 return tmp.
lssolve (b, info, rank, rcon);
2130 return tmp.
lssolve (b, info, rank, rcon);
2139 return tmp.
lssolve (b, info, rank, rcon);
2147 return tmp.
lssolve (b, info, rank, rcon);
2156 return lssolve (b, info, rank, rcon);
2164 return lssolve (b, info, rank, rcon);
2172 return lssolve (b, info, rank, rcon);
2187 (*current_liboctave_error_handler)
2188 (
"matrix dimension mismatch solution of linear equations");
2190 if (
m == 0 ||
n == 0)
2222 F77_CONST_CHAR_ARG2 (
" ", 1),
2224 F77_CHAR_ARG_LEN (6)
2225 F77_CHAR_ARG_LEN (1));
2229 float dminmn =
static_cast<float> (minmn);
2230 float dsmlsizp1 =
static_cast<float> (smlsiz+1);
2237 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
2246 F77_XFCN (sgelsd, SGELSD, (
m,
n, nrhs, tmp_data,
m, pretval, maxmn,
2248 lwork, piwork, tmp_info));
2253 lwork =
static_cast<F77_INT> (work(0));
2256 F77_XFCN (sgelsd, SGELSD, (
m,
n, nrhs, tmp_data,
m, pretval,
2257 maxmn, ps, rcon, tmp_rank,
2266 if (s.
elem (0) == 0.0)
2269 rcon = s.
elem (minmn - 1) / s.
elem (0);
2285 return tmp.
lssolve (b, info, rank, rcon);
2295 return tmp.
lssolve (b, info, rank, rcon);
2304 return tmp.
lssolve (b, info, rank, rcon);
2312 return tmp.
lssolve (b, info, rank, rcon);
2324 if (nr != a_nr || nc != a_nc)
2342 if (nr != a_nr || nc != a_nc)
2367 F77_XFCN (sgemm, SGEMM, (F77_CONST_CHAR_ARG2 (
"N", 1),
2368 F77_CONST_CHAR_ARG2 (
"N", 1),
2371 F77_CHAR_ARG_LEN (1)
2372 F77_CHAR_ARG_LEN (1)));
2430 if (nr == 1 || nc == 1)
2453 if (nr > 0 && nc > 0)
2464 for (idx_j = 0; idx_j < nc; idx_j++)
2466 tmp_min =
elem (i, idx_j);
2474 float tmp =
elem (i, j);
2478 else if (tmp < tmp_min)
2485 result.
elem (i) = tmp_min;
2508 if (nr > 0 && nc > 0)
2519 for (idx_j = 0; idx_j < nc; idx_j++)
2521 tmp_max =
elem (i, idx_j);
2529 float tmp =
elem (i, j);
2533 else if (tmp > tmp_max)
2540 result.
elem (i) = tmp_max;
2563 if (nr > 0 && nc > 0)
2574 for (idx_i = 0; idx_i < nr; idx_i++)
2576 tmp_min =
elem (idx_i, j);
2584 float tmp =
elem (i, j);
2588 else if (tmp < tmp_min)
2595 result.
elem (j) = tmp_min;
2618 if (nr > 0 && nc > 0)
2629 for (idx_i = 0; idx_i < nr; idx_i++)
2631 tmp_max =
elem (idx_i, j);
2639 float tmp =
elem (i, j);
2643 else if (tmp > tmp_max)
2650 result.
elem (j) = tmp_max;
2666 octave::write_value<float> (os, a.
elem (i, j));
2679 if (nr > 0 && nc > 0)
2685 tmp = octave::read_value<float> (is);
2687 a.
elem (i, j) = tmp;
2699 float cc, s, temp_r;
2701 F77_FUNC (slartg, SLARTG) (
x, y, cc, s, temp_r);
2722 octave::math::schur<FloatMatrix> as (a,
"U");
2723 octave::math::schur<FloatMatrix> bs (b,
"U");
2748 F77_XFCN (strsyl, STRSYL, (F77_CONST_CHAR_ARG2 (
"N", 1),
2749 F77_CONST_CHAR_ARG2 (
"N", 1),
2750 1, a_nr, b_nr, pa, a_nr, pb,
2751 b_nr, px, a_nr,
scale, info
2752 F77_CHAR_ARG_LEN (1)
2753 F77_CHAR_ARG_LEN (1)));
2784 get_blas_trans_arg (
bool trans)
2786 return trans ?
'T' :
'N';
2809 if (a_nr == 0 || a_nc == 0 || b_nc == 0)
2811 else if (a.
data () == b.
data () && a_nr == b_nc && tra != trb)
2818 const char ctra = get_blas_trans_arg (tra);
2819 F77_XFCN (ssyrk, SSYRK, (F77_CONST_CHAR_ARG2 (
"U", 1),
2820 F77_CONST_CHAR_ARG2 (&ctra, 1),
2822 a.
data (), lda, 0.0, c, a_nr
2823 F77_CHAR_ARG_LEN (1)
2824 F77_CHAR_ARG_LEN (1)));
2825 for (
int j = 0; j < a_nr; j++)
2826 for (
int i = 0; i < j; i++)
2846 const char ctra = get_blas_trans_arg (tra);
2847 F77_XFCN (sgemv, SGEMV, (F77_CONST_CHAR_ARG2 (&ctra, 1),
2848 lda, tda, 1.0, a.
data (), lda,
2849 b.
data (), 1, 0.0, c, 1
2850 F77_CHAR_ARG_LEN (1)));
2855 const char crevtrb = get_blas_trans_arg (! trb);
2856 F77_XFCN (sgemv, SGEMV, (F77_CONST_CHAR_ARG2 (&crevtrb, 1),
2857 ldb, tdb, 1.0, b.
data (), ldb,
2858 a.
data (), 1, 0.0, c, 1
2859 F77_CHAR_ARG_LEN (1)));
2863 const char ctra = get_blas_trans_arg (tra);
2864 const char ctrb = get_blas_trans_arg (trb);
2865 F77_XFCN (sgemm, SGEMM, (F77_CONST_CHAR_ARG2 (&ctra, 1),
2866 F77_CONST_CHAR_ARG2 (&ctrb, 1),
2867 a_nr, b_nc, a_nc, 1.0, a.
data (),
2868 lda, b.
data (), ldb, 0.0, c, a_nr
2869 F77_CHAR_ARG_LEN (1)
2870 F77_CHAR_ARG_LEN (1)));
2880 return xgemm (a, b);
2885 #define EMPTY_RETURN_CHECK(T) \
2886 if (nr == 0 || nc == 0) \
2936 (*current_liboctave_error_handler)
2937 (
"two-arg min requires same size arguments");
3000 (*current_liboctave_error_handler)
3001 (
"two-arg max requires same size arguments");
3026 (*current_liboctave_error_handler)
3027 (
"linspace: vectors must be of equal length");
3037 retval.clear (
m,
n);
3039 retval.insert (
linspace (x1(i), x2(i),
n), i, 0);
base_det< float > FloatDET
T & elem(octave_idx_type n)
Size of the specified dimension.
T * fortran_vec()
Size of the specified dimension.
Array< T, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
bool issquare() const
Size of the specified dimension.
octave_idx_type rows() const
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
const T * data() const
Size of the specified dimension.
octave_idx_type columns() const
octave_idx_type cols() const
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
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
void resize(octave_idx_type n, const float &rfv=0)
FloatColumnVector extract(octave_idx_type r1, octave_idx_type r2) const
FloatComplexMatrix lssolve(const FloatMatrix &b) const
FloatComplexMatrix solve(MatrixType &mattype, const FloatMatrix &b) const
FloatDiagMatrix inverse() const
FloatColumnVector extract_diag(octave_idx_type k=0) const
FloatMatrix sumsq(int dim=-1) const
FloatMatrix sum(int dim=-1) const
bool operator==(const FloatMatrix &a) const
void resize(octave_idx_type nr, octave_idx_type nc, float rfv=0)
FloatColumnVector row_max() const
FloatMatrix lssolve(const FloatMatrix &b) const
FloatComplexMatrix fourier2d() const
friend class FloatComplexMatrix
FloatMatrix & fill(float val)
FloatMatrix inverse() const
FloatMatrix prod(int dim=-1) const
FloatMatrix & insert(const FloatMatrix &a, octave_idx_type r, octave_idx_type c)
FloatRowVector row(octave_idx_type i) const
FloatMatrix & operator-=(const FloatDiagMatrix &a)
FloatComplexMatrix ifourier2d() const
FloatMatrix & operator+=(const FloatDiagMatrix &a)
FloatComplexMatrix ifourier() const
FloatMatrix solve(MatrixType &mattype, const FloatMatrix &b) const
FloatMatrix cumsum(int dim=-1) const
FloatComplexMatrix fourier() const
FloatRowVector column_min() const
FloatMatrix append(const FloatMatrix &a) const
FloatRowVector column_max() const
FloatMatrix diag(octave_idx_type k=0) const
bool operator!=(const FloatMatrix &a) const
FloatColumnVector row_min() const
FloatMatrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
FloatMatrix cumprod(int dim=-1) const
FloatMatrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
FloatColumnVector column(octave_idx_type i) const
FloatDET determinant() const
FloatMatrix transpose() const
FloatMatrix stack(const FloatMatrix &a) const
FloatMatrix pseudo_inverse(float tol=0.0) const
FloatNDArray sum(int dim=-1) const
FloatNDArray prod(int dim=-1) const
FloatNDArray cumprod(int dim=-1) const
FloatNDArray & insert(const FloatNDArray &a, octave_idx_type r, octave_idx_type c)
FloatNDArray cumsum(int dim=-1) const
FloatNDArray sumsq(int dim=-1) const
FloatNDArray diag(octave_idx_type k=0) const
void resize(octave_idx_type n, const float &rfv=0)
void mark_as_unsymmetric()
int type(bool quiet=true)
void mark_as_rectangular()
octave_idx_type rows() const
const Array< octave_idx_type > & col_perm_vec() const
Vector representing the dimensions (size) of an Array.
#define F77_XFCN(f, F, args)
octave_f77_int_type F77_INT
std::ostream & operator<<(std::ostream &os, const FloatMatrix &a)
FloatMatrix operator*(const FloatColumnVector &v, const FloatRowVector &a)
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)
FloatMatrix max(float d, const FloatMatrix &m)
std::istream & operator>>(std::istream &is, 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)
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< float > FloatComplex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
F77_RET_T F77_FUNC(xerbla, XERBLA)(F77_CONST_CHAR_ARG_DEF(s_arg
subroutine xilaenv(ispec, name, opts, n1, n2, n3, n4, retval)
subroutine xsdot(n, dx, incx, dy, incy, retval)