Mercurial > hg > octave-terminal
changeset 3473:64f8babb7b3d
[project @ 2000-01-25 09:44:15 by jwe]
author | jwe |
---|---|
date | Tue, 25 Jan 2000 09:44:17 +0000 |
parents | 9c509e1cbf49 |
children | 9c68cfa263eb |
files | ChangeLog emacs/octave-mod.el liboctave/Array2.cc liboctave/Array2.h liboctave/ChangeLog scripts/ChangeLog scripts/statistics/distributions/weibull_pdf.m |
diffstat | 7 files changed, 72 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-01-24 John W. Eaton <jwe@bevo.che.wisc.edu> + + * emacs/octave-mod.el (octave-mode-syntax-table): + Make `%' a comment start character too. + 2000-01-20 John W. Eaton <jwe@bevo.che.wisc.edu> * configure.in: Check for strptime and localtime_r.
--- a/emacs/octave-mod.el +++ b/emacs/octave-mod.el @@ -301,7 +301,7 @@ (modify-syntax-entry ?\" "\"" table) (modify-syntax-entry ?. "w" table) (modify-syntax-entry ?_ "w" table) - (modify-syntax-entry ?\% "." table) + (modify-syntax-entry ?\% "<" table) (modify-syntax-entry ?\# "<" table) (modify-syntax-entry ?\n ">" table) (setq octave-mode-syntax-table table)))
--- a/liboctave/Array2.cc +++ b/liboctave/Array2.cc @@ -43,6 +43,51 @@ #include "lo-error.h" template <class T> +int +Array2<T>::get_size (int r, int c) const +{ + // XXX KLUGE XXX + + // If an allocation of an array with r * c elements of type T + // would cause an overflow in the allocator when computing the + // size of the allocation, then return a value which, although + // not equivalent to the actual request, should be too large for + // most current hardware, but not so large to cause the + // allocator to barf on computing retval * sizeof (T). + + // A guess (should be quite conservative). + static const int MALLOC_OVERHEAD = 1024; + + static int nl; + static double dl + = frexp (static_cast<double> + (INT_MAX - MALLOC_OVERHEAD) / sizeof (T), &nl); + + // This value should be an integer. If we return this value and + // things work the way we expect, we should be paying a visit to + // new_handler in no time flat. + static int max_items = static_cast<int> (ldexp (dl, nl)); + + int nr, nc; + double dr = frexp (static_cast<double> (r), &nr); + double dc = frexp (static_cast<double> (c), &nc); + + int nt = nr + nc; + double dt = dr * dc; + + if (dt <= 0.5) + { + nt--; + dt *= 2; + + if (dt <= 0.5) + nt--; + } + + return (nt < nl || (nt == nl && dt < dl)) ? r * c : max_items; +} + +template <class T> T Array2<T>::range_error (const char *fcn, int i, int j) const { @@ -84,7 +129,7 @@ int old_d2 = dim2 (); int old_len = length (); - rep = new ArrayRep (r*c); + rep = new ArrayRep (get_size (r, c)); d1 = r; d2 = c; @@ -124,7 +169,7 @@ int old_d2 = dim2 (); int old_len = length (); - rep = new ArrayRep (r*c); + rep = new ArrayRep (get_size (r, c)); d1 = r; d2 = c;
--- a/liboctave/Array2.h +++ b/liboctave/Array2.h @@ -29,6 +29,8 @@ #endif #include <cassert> +#include <climits> +#include <cmath> #include <cstdlib> #include "Array.h" @@ -41,9 +43,13 @@ template <class T> class Array2 : public Array<T> { +private: + + int get_size (int r, int c) const; + protected: - Array2 (T *d, int n, int m) : Array<T> (d, n*m) + Array2 (T *d, int n, int m) : Array<T> (d, get_size (n, m)) { d1 = n; d2 = m; @@ -66,14 +72,14 @@ set_max_indices (2); } - Array2 (int n, int m) : Array<T> (n*m) + Array2 (int n, int m) : Array<T> (get_size (n, m)) { d1 = n; d2 = m; set_max_indices (2); } - Array2 (int n, int m, const T& val) : Array<T> (n*m, val) + Array2 (int n, int m, const T& val) : Array<T> (get_size (n, m), val) { d1 = n; d2 = m;
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2000-01-25 John W. Eaton <jwe@bevo.che.wisc.edu> + + * Array2.cc (Array2<T>::get_size): New function. + (Array2<T>::Array2, Array2<T>::resize): Use it. + 2000-01-23 John W. Eaton <jwe@bevo.che.wisc.edu> * Array2-idx.h (Array2<T>::maybe_delete_elements (idx_vector&)):
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2000-01-24 Cyril Humbert <humbert@phobos.univ-mlv.fr> + + * statistics/distributions/weibull_pdf.m: Use correct formula. + 2000-01-22 Michael Reifenberger <mike@Plaut.de> * audio/saveaudio.m: Also accept files with .ul extension.
--- a/scripts/statistics/distributions/weibull_pdf.m +++ b/scripts/statistics/distributions/weibull_pdf.m @@ -58,7 +58,7 @@ k = find ((x > 0) & (x < Inf) & ok); if (any (k)) - pdf(k) = (shape(k) .* (scale(k) .^ shape(k)) + pdf(k) = (shape(k) .* (scale(k) .^ -shape(k)) .* (x(k) .^ (shape(k) - 1)) .* exp(- (x(k) ./ scale(k)) .^ shape(k))); endif