Mercurial > hg > octave-avbm
changeset 10258:e317791645c4
64-bit fixes
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 03 Feb 2010 15:27:53 -0500 |
parents | cd550069240e |
children | 65b41bc71f09 |
files | liboctave/Array.cc liboctave/ChangeLog liboctave/CmplxSVD.cc liboctave/dbleSVD.cc liboctave/fCmplxSVD.cc liboctave/floatSVD.cc liboctave/idx-vector.cc liboctave/lo-specfun.cc src/ChangeLog src/DLD-FUNCTIONS/lookup.cc src/DLD-FUNCTIONS/qr.cc src/DLD-FUNCTIONS/strfind.cc src/DLD-FUNCTIONS/sub2ind.cc src/DLD-FUNCTIONS/tril.cc src/oct-stream.cc src/ov-struct.cc |
diffstat | 16 files changed, 91 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -2389,8 +2389,9 @@ else { octave_idx_type nnan = ns - ku; - lsort.nth_element (buf, ku, std::max (lo - nnan, 0), - std::max (up - nnan, 0)); + octave_idx_type zero = 0; + lsort.nth_element (buf, ku, std::max (lo - nnan, zero), + std::max (up - nnan, zero)); std::rotate (buf, buf + ku, buf + ns); }
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,15 @@ +2010-02-03 John W. Eaton <jwe@octave.org> + + * dbleSVD.cc (SVD::init): Ensure args to std::max are the same type. + * CmplxSVD.cc (ComplexSVD::init): Likewise. + * floatSVD.cc (FloatSVD::init): Likewise. + * fCmplxSVD.cc (FloatComplexSVD::init): Likewise. + * idx-vector.cc (idx_range_rep): Likewise. + * Array.cc (Array<T>::nth_element): Likewise. + + * lo-specfun.cc (null_dims): Delete unused static variable. + (betainc): Call dim_vector (0, 0), not dim_vector (0). + 2010-02-03 John W. Eaton <jwe@octave.org> * file-ops.h (octave_canonicalize_file_name): Rename from
--- a/liboctave/CmplxSVD.cc +++ b/liboctave/CmplxSVD.cc @@ -141,7 +141,8 @@ Array<Complex> work (1); - octave_idx_type m1 = std::max (m, 1), nrow_vt1 = std::max (nrow_vt, 1); + octave_idx_type one = 1; + octave_idx_type m1 = std::max (m, one), nrow_vt1 = std::max (nrow_vt, one); F77_XFCN (zgesvd, ZGESVD, (F77_CONST_CHAR_ARG2 (&jobu, 1), F77_CONST_CHAR_ARG2 (&jobv, 1),
--- a/liboctave/dbleSVD.cc +++ b/liboctave/dbleSVD.cc @@ -137,7 +137,8 @@ Array<double> work (1); - octave_idx_type m1 = std::max (m, 1), nrow_vt1 = std::max (nrow_vt, 1); + octave_idx_type one = 1; + octave_idx_type m1 = std::max (m, one), nrow_vt1 = std::max (nrow_vt, one); F77_XFCN (dgesvd, DGESVD, (F77_CONST_CHAR_ARG2 (&jobu, 1), F77_CONST_CHAR_ARG2 (&jobv, 1),
--- a/liboctave/fCmplxSVD.cc +++ b/liboctave/fCmplxSVD.cc @@ -141,7 +141,8 @@ Array<FloatComplex> work (1); - octave_idx_type m1 = std::max (m, 1), nrow_vt1 = std::max (nrow_vt, 1); + octave_idx_type one = 1; + octave_idx_type m1 = std::max (m, one), nrow_vt1 = std::max (nrow_vt, one); F77_XFCN (cgesvd, CGESVD, (F77_CONST_CHAR_ARG2 (&jobu, 1), F77_CONST_CHAR_ARG2 (&jobv, 1),
--- a/liboctave/floatSVD.cc +++ b/liboctave/floatSVD.cc @@ -137,7 +137,8 @@ Array<float> work (1); - octave_idx_type m1 = std::max (m, 1), nrow_vt1 = std::max (nrow_vt, 1); + octave_idx_type one = 1; + octave_idx_type m1 = std::max (m, one), nrow_vt1 = std::max (nrow_vt, one); F77_XFCN (sgesvd, SGESVD, (F77_CONST_CHAR_ARG2 (&jobu, 1), F77_CONST_CHAR_ARG2 (&jobv, 1),
--- a/liboctave/idx-vector.cc +++ b/liboctave/idx-vector.cc @@ -93,9 +93,10 @@ DEFINE_OCTAVE_ALLOCATOR(idx_vector::idx_range_rep); -idx_vector::idx_range_rep::idx_range_rep (octave_idx_type _start, octave_idx_type _limit, +idx_vector::idx_range_rep::idx_range_rep (octave_idx_type _start, + octave_idx_type _limit, octave_idx_type _step) - : start(_start), len (_step ? std::max((_limit - _start) / _step, 0) : -1), step (_step) + : start(_start), len (_step ? std::max((_limit - _start) / _step, static_cast<octave_idx_type> (0)) : -1), step (_step) { if (len < 0) {
--- a/liboctave/lo-specfun.cc +++ b/liboctave/lo-specfun.cc @@ -2095,8 +2095,6 @@ r1, c1, r2, c2, r3, c3); } -static dim_vector null_dims (0); - static void gripe_betainc_nonconformant (const dim_vector& d1, const dim_vector& d2, const dim_vector& d3) @@ -2217,7 +2215,7 @@ retval (i) = betainc (x, a(i), b(i)); } else - gripe_betainc_nonconformant (dim_vector (0), dv, b.dims ()); + gripe_betainc_nonconformant (dim_vector (0, 0), dv, b.dims ()); return retval; } @@ -2346,7 +2344,7 @@ retval (i) = betainc (x(i), a, b(i)); } else - gripe_betainc_nonconformant (dv, dim_vector (0), b.dims ()); + gripe_betainc_nonconformant (dv, dim_vector (0, 0), b.dims ()); return retval; } @@ -2367,7 +2365,7 @@ retval (i) = betainc (x(i), a(i), b); } else - gripe_betainc_nonconformant (dv, a.dims (), dim_vector (0)); + gripe_betainc_nonconformant (dv, a.dims (), dim_vector (0, 0)); return retval; } @@ -2500,7 +2498,7 @@ retval (i) = betainc (x, a(i), b(i)); } else - gripe_betainc_nonconformant (dim_vector (0), dv, b.dims ()); + gripe_betainc_nonconformant (dim_vector (0, 0), dv, b.dims ()); return retval; } @@ -2629,7 +2627,7 @@ retval (i) = betainc (x(i), a, b(i)); } else - gripe_betainc_nonconformant (dv, dim_vector (0), b.dims ()); + gripe_betainc_nonconformant (dv, dim_vector (0, 0), b.dims ()); return retval; } @@ -2650,7 +2648,7 @@ retval (i) = betainc (x(i), a(i), b); } else - gripe_betainc_nonconformant (dv, a.dims (), dim_vector (0)); + gripe_betainc_nonconformant (dv, a.dims (), dim_vector (0, 0)); return retval; }
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,21 @@ +2010-02-03 John W. Eaton <jwe@octave.org> + + * DLD-FUNCTIONS/sub2ind.cc (get_dim_vector): + Eliminate unnecessary cast. + + * DLD-FUNCTIONS/qr.cc (Fqrinsert, Fqrdelete): + Avoid type mismatch errors with octave_idx_type. + + * oct-stream.cc (scanf_format_list::add_elt_to_list): + NUM_ELTS arg is octave_idx_type, not int. + + * ov-struct.cc (octave_struct::load_ascii): Ensure args to + std::max are the same type. + * DLD-FUNCTIONS/lookup.cc (do_numeric_lookup): Likewise. + * DLD-FUNCTIONS/sub2ind.cc (get_dim_vector): Likewise. + * DLD-FUNCTIONS/strfind.cc (qs_search): Likewise, for std::min. + * DLD-FUNCTIONS/tril.cc (do_tril, do_triu): Likewise. + 2010-02-03 John W. Eaton <jwe@octave.org> * utils.cc (octave_vsnprintf): Assume we have vsnprintf with
--- a/src/DLD-FUNCTIONS/lookup.cc +++ b/src/DLD-FUNCTIONS/lookup.cc @@ -144,16 +144,18 @@ { for (octave_idx_type i = 0; i < nval; i++) { + octave_idx_type one = 1; octave_idx_type j = idx.xelem (i); - ridx.xelem (i) = std::min (std::max (1, j), n-1); + ridx.xelem (i) = std::min (std::max (one, j), n-1); } } else if (left_inf) { + octave_idx_type one = 1; for (octave_idx_type i = 0; i < nval; i++) { octave_idx_type j = idx.xelem (i); - ridx.xelem (i) = std::max (1, j); + ridx.xelem (i) = std::max (one, j); } } else if (right_inf)
--- a/src/DLD-FUNCTIONS/qr.cc +++ b/src/DLD-FUNCTIONS/qr.cc @@ -1003,6 +1003,8 @@ MArray<octave_idx_type> j = argj.octave_idx_type_vector_value (); + octave_idx_type one = 1; + if (argq.is_real_type () && argr.is_real_type () && argx.is_real_type ()) @@ -1019,9 +1021,9 @@ FloatQR fact (Q, R); if (col) - fact.insert_col (x, j-1); + fact.insert_col (x, j-one); else - fact.insert_row (x.row (0), j(0)-1); + fact.insert_row (x.row (0), j(0)-one); retval(1) = get_qr_r (fact); retval(0) = fact.Q (); @@ -1036,9 +1038,9 @@ QR fact (Q, R); if (col) - fact.insert_col (x, j-1); + fact.insert_col (x, j-one); else - fact.insert_row (x.row (0), j(0)-1); + fact.insert_row (x.row (0), j(0)-one); retval(1) = get_qr_r (fact); retval(0) = fact.Q (); @@ -1059,9 +1061,9 @@ FloatComplexQR fact (Q, R); if (col) - fact.insert_col (x, j-1); + fact.insert_col (x, j-one); else - fact.insert_row (x.row (0), j(0)-1); + fact.insert_row (x.row (0), j(0)-one); retval(1) = get_qr_r (fact); retval(0) = fact.Q (); @@ -1075,9 +1077,9 @@ ComplexQR fact (Q, R); if (col) - fact.insert_col (x, j-1); + fact.insert_col (x, j-one); else - fact.insert_row (x.row (0), j(0)-1); + fact.insert_row (x.row (0), j(0)-one); retval(1) = get_qr_r (fact); retval(0) = fact.Q (); @@ -1217,6 +1219,8 @@ MArray<octave_idx_type> j = argj.octave_idx_type_vector_value (); + octave_idx_type one = 1; + if (argq.is_real_type () && argr.is_real_type ()) { @@ -1230,9 +1234,9 @@ FloatQR fact (Q, R); if (col) - fact.delete_col (j-1); + fact.delete_col (j-one); else - fact.delete_row (j(0)-1); + fact.delete_row (j(0)-one); retval(1) = get_qr_r (fact); retval(0) = fact.Q (); @@ -1245,9 +1249,9 @@ QR fact (Q, R); if (col) - fact.delete_col (j-1); + fact.delete_col (j-one); else - fact.delete_row (j(0)-1); + fact.delete_row (j(0)-one); retval(1) = get_qr_r (fact); retval(0) = fact.Q (); @@ -1265,9 +1269,9 @@ FloatComplexQR fact (Q, R); if (col) - fact.delete_col (j-1); + fact.delete_col (j-one); else - fact.delete_row (j(0)-1); + fact.delete_row (j(0)-one); retval(1) = get_qr_r (fact); retval(0) = fact.Q (); @@ -1280,9 +1284,9 @@ ComplexQR fact (Q, R); if (col) - fact.delete_col (j-1); + fact.delete_col (j-one); else - fact.delete_row (j(0)-1); + fact.delete_row (j(0)-one); retval(1) = get_qr_r (fact); retval(0) = fact.Q ();
--- a/src/DLD-FUNCTIONS/strfind.cc +++ b/src/DLD-FUNCTIONS/strfind.cc @@ -132,7 +132,8 @@ } octave_idx_type nmatch = accum.size (); - Array<octave_idx_type> result (dim_vector (std::min (1, nmatch), nmatch)); + octave_idx_type one = 1; + Array<octave_idx_type> result (dim_vector (std::min (one, nmatch), nmatch)); octave_idx_type k = 0; for (std::deque<octave_idx_type>::const_iterator iter = accum.begin (); iter != accum.end (); iter++)
--- a/src/DLD-FUNCTIONS/sub2ind.cc +++ b/src/DLD-FUNCTIONS/sub2ind.cc @@ -33,8 +33,7 @@ static dim_vector -get_dim_vector (const octave_value& val, - const char *name) +get_dim_vector (const octave_value& val, const char *name) { RowVector dimsv = val.row_vector_value (false, true); dim_vector dv; @@ -44,11 +43,11 @@ error ("%s: dimension vector must not be empty", name); else { - dv.resize (std::max (n, 2)); + dv.resize (std::max (n, static_cast<octave_idx_type> (2))); dv(1) = 1; for (octave_idx_type i = 0; i < n; i++) { - octave_idx_type ii = static_cast<int> (dimsv(i)); + octave_idx_type ii = dimsv(i); if (ii == dimsv(i) && ii >= 0) dv(i) = ii; else
--- a/src/DLD-FUNCTIONS/tril.cc +++ b/src/DLD-FUNCTIONS/tril.cc @@ -42,17 +42,18 @@ { octave_idx_type nr = a.rows (), nc = a.columns (); const T *avec = a.fortran_vec (); + octave_idx_type zero = 0; if (pack) { - octave_idx_type j1 = std::min (std::max (0, k), nc); - octave_idx_type j2 = std::min (std::max (0, nr + k), nc); + octave_idx_type j1 = std::min (std::max (zero, k), nc); + octave_idx_type j2 = std::min (std::max (zero, nr + k), nc); octave_idx_type n = j1 * nr + ((j2 - j1) * (nr-(j1-k) + nr-(j2-1-k))) / 2; Array<T> r (n); T *rvec = r.fortran_vec (); for (octave_idx_type j = 0; j < nc; j++) { - octave_idx_type ii = std::min (std::max (0, j - k), nr); + octave_idx_type ii = std::min (std::max (zero, j - k), nr); rvec = std::copy (avec + ii, avec + nr, rvec); avec += nr; } @@ -65,7 +66,7 @@ T *rvec = r.fortran_vec (); for (octave_idx_type j = 0; j < nc; j++) { - octave_idx_type ii = std::min (std::max (0, j - k), nr); + octave_idx_type ii = std::min (std::max (zero, j - k), nr); std::fill (rvec, rvec + ii, T()); std::copy (avec + ii, avec + nr, rvec + ii); avec += nr; @@ -82,17 +83,18 @@ { octave_idx_type nr = a.rows (), nc = a.columns (); const T *avec = a.fortran_vec (); + octave_idx_type zero = 0; if (pack) { - octave_idx_type j1 = std::min (std::max (0, k), nc); - octave_idx_type j2 = std::min (std::max (0, nr + k), nc); + octave_idx_type j1 = std::min (std::max (zero, k), nc); + octave_idx_type j2 = std::min (std::max (zero, nr + k), nc); octave_idx_type n = ((j2 - j1) * ((j1+1-k) + (j2-k))) / 2 + (nc - j2) * nr; Array<T> r (n); T *rvec = r.fortran_vec (); for (octave_idx_type j = 0; j < nc; j++) { - octave_idx_type ii = std::min (std::max (0, j + 1 - k), nr); + octave_idx_type ii = std::min (std::max (zero, j + 1 - k), nr); rvec = std::copy (avec, avec + ii, rvec); avec += nr; } @@ -105,7 +107,7 @@ T *rvec = r.fortran_vec (); for (octave_idx_type j = 0; j < nc; j++) { - octave_idx_type ii = std::min (std::max (0, j + 1 - k), nr); + octave_idx_type ii = std::min (std::max (zero, j + 1 - k), nr); std::copy (avec, avec + ii, rvec); std::fill (rvec + ii, rvec + nr, T()); avec += nr;