# HG changeset patch # User jwe # Date 954545606 0 # Node ID 84b2f30007d5f4155e4f55c7deab71455888cda6 # Parent 25e84fcef38a3cbfe347cf1c86f4ac2c9171ddb5 [project @ 2000-03-31 23:33:25 by jwe] diff --git a/scripts/statistics/distributions/beta_inv.m b/scripts/statistics/distributions/beta_inv.m --- a/scripts/statistics/distributions/beta_inv.m +++ b/scripts/statistics/distributions/beta_inv.m @@ -68,7 +68,7 @@ endif y_old = y; - for i = 1 : 100 + for i = 1 : 10000 h = (beta_cdf (y_old, a, b) - x) ./ beta_pdf (y_old, a, b); y_new = y_old - h; ind = find (y_new <= eps); diff --git a/scripts/statistics/distributions/f_inv.m b/scripts/statistics/distributions/f_inv.m --- a/scripts/statistics/distributions/f_inv.m +++ b/scripts/statistics/distributions/f_inv.m @@ -54,7 +54,11 @@ k = find ((x > 0) & (x < 1) & (m > 0) & (n > 0)); if (any (k)) - inv(k) = ((1 ./ beta_inv (1 - x(k), n(k) / 2, m(k) / 2) - 1) + fprintf (stderr, "n1: %f\n", n(k)); + fprintf (stderr, "n2: %f\n", m(k)); + t = beta_inv (1 - x(k), n(k) / 2, m(k) / 2) + fprintf (stderr, "qbeta: %f\n", t); + inv(k) = ((1 ./ t - 1) .* n(k) ./ m(k)); endif diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2000-03-31 John W. Eaton + * oct-stream.cc (printf_value_cache::string_value): Return string + matrices in a Matlab-compatible way. + (printf_value_cache): Redesign the way list_exhausted works. + * oct-fstrm.cc (octave_fstream::do_close): New function. * oct-stdstrm.cc (octave_istdiostream::do_close): Ditto. (octave_ostdiostream::do_close): Ditto. diff --git a/src/oct-stream.cc b/src/oct-stream.cc --- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -1970,7 +1970,7 @@ { public: - enum state { ok, list_exhausted, conversion_error }; + enum state { ok, conversion_error }; printf_value_cache (const octave_value_list& args) : values (args), val_idx (0), elt_idx (0), @@ -1990,8 +1990,7 @@ operator bool () const { return (curr_state == ok); } - bool exhausted (void) - { return (curr_state == list_exhausted || val_idx >= n_vals); } + bool exhausted (void) { return (val_idx >= n_vals); } bool looking_at_string (void); @@ -2022,26 +2021,10 @@ { bool retval = false; - int idx = -1; - - if (elt_idx == 0) - idx = val_idx; - else if (elt_idx >= n_elts) - idx = val_idx + 1; + int idx = (elt_idx == 0) ? val_idx : -1; if (idx >= 0 && idx < n_vals) - { - octave_value tmp_val = values (idx); - - // An empty string has zero rows and zero columns. - - if (tmp_val.is_string ()) - { - int nr = tmp_val.rows (); - - retval = (nr == 1 || (nr == 0 && tmp_val.columns () == 0)); - } - } + retval = values(idx).is_string (); return retval; } @@ -2074,7 +2057,15 @@ if (elt_idx < n_elts) { - return data[elt_idx++]; + retval = data[elt_idx++]; + + if (elt_idx >= n_elts) + { + elt_idx = 0; + val_idx++; + data = 0; + } + break; } else @@ -2085,8 +2076,6 @@ } } - curr_state = list_exhausted; - return retval; } @@ -2115,14 +2104,27 @@ if (looking_at_string ()) { - if (elt_idx != 0) + octave_value tval = values (val_idx++); + + if (tval.rows () == 1) + retval = tval.string_value (); + else { - val_idx++; - elt_idx = 0; - data = 0; + // In the name of Matlab compatibility. + + charMatrix chm = tval.char_matrix_value (); + + int nr = chm.rows (); + int nc = chm.columns (); + + int k = 0; + + retval.resize (nr * nc, '\0'); + + for (int j = 0; j < nc; j++) + for (int i = 0; i < nr; i++) + retval[k++] = chm(i,j); } - - retval = values (val_idx++).string_value (); } else curr_state = conversion_error;