Mercurial > hg > octave-jordi
changeset 4911:14027e0bafa4
[project @ 2004-07-22 19:58:06 by jwe]
author | jwe |
---|---|
date | Thu, 22 Jul 2004 19:58:06 +0000 |
parents | 1242acab4246 |
children | 048db020498c |
files | liboctave/ChangeLog liboctave/lo-specfun.cc liboctave/oct-sort.h scripts/ChangeLog scripts/general/num2str.m scripts/general/sub2ind.m scripts/image/imshow.m scripts/miscellaneous/unix.m scripts/plot/figure.m src/ChangeLog src/data.cc src/ov-cx-mat.h src/ov-re-mat.h src/ov-struct.cc src/ov.cc src/ov.h src/pt-loop.cc src/symtab.cc |
diffstat | 18 files changed, 187 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,11 @@ +2004-07-22 David Bateman <dbateman@free.fr> + + * oct-sort.h: Don't include oct-obj.h. + + * lo-specfun.cc (is_integer_value): New function. + (zbesj, zbesi, zbesy): Special case negative integer or half + integer orders that cause overflow for small arguments. + 2004-07-12 John W. Eaton <jwe@octave.org> * oct-inttypes.h (octave_int<T>::nbits): New function.
--- a/liboctave/lo-specfun.cc +++ b/liboctave/lo-specfun.cc @@ -223,6 +223,12 @@ return retval; } +static inline bool +is_integer_value (double x) +{ + return x == static_cast<double> (static_cast<long> (x)); +} + static inline Complex zbesj (const Complex& z, double alpha, int kode, int& ierr) { @@ -252,6 +258,15 @@ retval = bessel_return_value (Complex (yr, yi), ierr); } + else if (is_integer_value (alpha)) + { + // zbesy can overflow as z->0, and cause troubles for generic case below + alpha = -alpha; + Complex tmp = zbesj (z, alpha, kode, ierr); + if ((static_cast <long> (alpha)) & 1) + tmp = - tmp; + retval = bessel_return_value (tmp, ierr); + } else { alpha = -alpha; @@ -313,6 +328,15 @@ return bessel_return_value (Complex (yr, yi), ierr); } + else if (is_integer_value (alpha - 0.5)) + { + // zbesy can overflow as z->0, and cause troubles for generic case below + alpha = -alpha; + Complex tmp = zbesj (z, alpha, kode, ierr); + if ((static_cast <long> (alpha - 0.5)) & 1) + tmp = - tmp; + retval = bessel_return_value (tmp, ierr); + } else { alpha = -alpha; @@ -369,8 +393,9 @@ if (ierr == 0 || ierr == 3) { - tmp += (2.0 / M_PI) * sin (M_PI * alpha) - * zbesk (z, alpha, kode, ierr); + if (! is_integer_value (alpha - 0.5)) + tmp += (2.0 / M_PI) * sin (M_PI * alpha) + * zbesk (z, alpha, kode, ierr); retval = bessel_return_value (tmp, ierr); }
--- a/liboctave/oct-sort.h +++ b/liboctave/oct-sort.h @@ -86,7 +86,6 @@ #include <config.h> #endif -#include "oct-obj.h" #include "lo-mappers.h" #include "quit.h"
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,22 @@ +2004-07-22 Etienne Grossmann <etienne@cs.uky.edu> + + * general/sub2ind.m: Make reshaping index list unnecessary. + +2004-07-22 Paul Kienzle <pkienzle@users.sf.net> + + * miscellaneous/unix.m: Fix doc string. + +2004-07-22 Stefan van der Walt <stefan@sun.ac.za> + + * plot/figure.m: Clarification of documentation. + + * image/imshow.m: Warn for complex images. + Only estimate colourmap for images in [0, 65536]. + +2004-07-22 David Bateman <dbateman@free.fr> + + * general/num2str.m: Fix the case of an all zero input. + 2004-06-22 Etienne Grossmann <etienne@cs.uky.edu> * general/ind2sub.m: Doc fix.
--- a/scripts/general/num2str.m +++ b/scripts/general/num2str.m @@ -107,7 +107,11 @@ endif else if (isnumeric (x) && round (x) == x && abs (x) < 1e10) - dgt = ceil(log10(max(abs(x(:)))))+ (min (real (x(:))) < 0); + if (max(abs(x(:))) == 0) + dgt = 1; + else + dgt = floor(log10(max(abs(x(:))))) + (min (real (x(:))) < 0) + 1; + endif fmt = sprintf("%%%dd ",dgt); elseif (isscalar (x)) fmt = "%.4g";
--- a/scripts/general/sub2ind.m +++ b/scripts/general/sub2ind.m @@ -46,9 +46,9 @@ error ("sub2ind: index out of range"); endif else - if (all (size (first_arg) == size (arg))) + if (prod (size (first_arg)) == prod (size (arg))) if ((i > nd && arg == 1) || (arg > 0 & arg <= dims(i))) - ind += scale(i-1) * (arg - 1); + ind(:) += scale(i-1) * (arg(:) - 1); else error ("sub2ind: index out of range"); endif
--- a/scripts/image/imshow.m +++ b/scripts/image/imshow.m @@ -68,7 +68,11 @@ if (mvars != 3) I = varargin{1}; - if (max (varargin{1}(:)) <= 1) + if iscomplex (I) + warning("imshow: displaying real part of complex image"); + I = real (I); + endif + if (max (I(:)) <= 1) # image in [0-1]; scale to [0-255] I = I * 255; M = gray (256); @@ -79,7 +83,12 @@ ## imshow (x) ## Grayscale image [0-N] -- estimate gray levels. N = 2^ceil (log2 (max(I(:)))); - M = gray (N); + if (N <= 65536) + M = gray (N); + else + M = gray (256); + I = I / max (I(:)) * 255; + endif elseif (mvars == 2) ## imshow (x, map) or imshow (x, N) M = varargin{2}; @@ -92,6 +101,10 @@ g = varargin{2}; b = varargin{3}; tmp = [r; g; b]; + if iscomplex (tmp) + warning("imshow: displaying real part of complex rgb image"); + r = real (r); g = real (g); b = real (b); + endif if (max (tmp(:)) > 1) ## Normalise to [0-1]. r = r/255;
--- a/scripts/miscellaneous/unix.m +++ b/scripts/miscellaneous/unix.m @@ -18,13 +18,15 @@ ## 02111-1307, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{status}, @var{text}]} isunix (@var{command}) -## @deftypefnx {Function File} {[@var{status}, @var{text}]} isunix (@var{command}, "-echo") +## @deftypefn {Function File} {[@var{status}, @var{text}]} unix (@var{command}) +## @deftypefnx {Function File} {[@var{status}, @var{text}]} unix (@var{command}, "-echo") ## Execute a system command if running under a Unix-like operating ## system, otherwise do nothing. Return the exit status of the program ## in @var{status} and any output sent to the standard output in ## @var{text}. If the optional second argument @code{"-echo"} is given, ## then also send the output from the command to the standard output. +## @end deftypefn +## @seealso{isunix, ispc, system} ## Author: octave-forge ??? ## Adapted by: jwe
--- a/scripts/plot/figure.m +++ b/scripts/plot/figure.m @@ -21,7 +21,8 @@ ## @deftypefn {Function File} {} figure (@var{n}) ## Set the current plot window to plot window @var{n}. This function ## currently requires X11 and a version of gnuplot that supports multiple -## frames. +## frames. If N is not specified, the next available window number is +## chosen. ## @end deftypefn ## Author: jwe
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,26 @@ +2004-07-22 Paul Kienzle <pkienzle@users.sf.net> + + * DLD-FUNCTIONS/dassl.cc (Fdassl): Fix doc string. + * ov-struct.cc (Fstruct): Likewise. + * symtab.cc (Fdebug_symtab_lookups): Likewise. + +2004-07-22 David Bateman <dbateman@free.fr> + + * data.cc (Fsize): Return 1 for dimensions exceeding ndim. + + * ov.cc (octave_value::octave_value (const ArrayN<double>)): + New constructor. + * ov.h: Provide decl. + * ov-cx-mat.h (octave_complex_matrix (const ArrayN<Complex>&)): + New constructor. + * ov-re-mat.h (octave_complex_matrix (const ArrayN<double>&)): + New constructor. + + * ov-re-mat.h (octave_matrix(const ArrayN<double>&)): New constructor + * pt-loop.cc (DO_ND_LOOP): New macro for use of NDArray in for loop. + (tree_simple_for_command::eval): Use it, and allow iteration over + cell arrays. + 2004-07-12 John W. Eaton <jwe@octave.org> * ov-intx.h: N-d array and scalar extractor functions take no args.
--- a/src/data.cc +++ b/src/data.cc @@ -1236,8 +1236,13 @@ { dim_vector dv = args(0).dims (); - if (nd > 0 && nd <= dv.length ()) - retval(0) = dv(nd-1); + if (nd > 0) + { + if (nd <= dv.length ()) + retval(0) = dv(nd-1); + else + retval(0) = 1; + } else error ("size: requested dimension (= %d) out of range", nd); }
--- a/src/ov-cx-mat.h +++ b/src/ov-cx-mat.h @@ -62,6 +62,9 @@ octave_complex_matrix (const ComplexMatrix& m) : octave_base_matrix<ComplexNDArray> (m) { } + octave_complex_matrix (const ArrayN<Complex>& m) + : octave_base_matrix<ComplexNDArray> (ComplexNDArray (m)) { } + octave_complex_matrix (const ComplexDiagMatrix& d) : octave_base_matrix<ComplexNDArray> (ComplexMatrix (d)) { }
--- a/src/ov-re-mat.h +++ b/src/ov-re-mat.h @@ -63,6 +63,9 @@ octave_matrix (const NDArray& nda) : octave_base_matrix<NDArray> (nda) { } + octave_matrix (const ArrayN<double>& m) + : octave_base_matrix<NDArray> (NDArray (m)) { } + octave_matrix (const DiagMatrix& d) : octave_base_matrix<NDArray> (Matrix (d)) { }
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -510,7 +510,8 @@ its values. The dimensions of each cell array of values must match.\n\ Singleton cells and non-cell values are repeated so that they fill\n\ the entire array. If the cells are empty, create an empty structure\n\ -array with the specified field names.") +array with the specified field names.\n\ +@end deftypefn") { octave_value_list retval;
--- a/src/ov.cc +++ b/src/ov.cc @@ -447,6 +447,13 @@ maybe_mutate (); } +octave_value::octave_value (const ArrayN<double>& a) + : rep (new octave_matrix (a)) +{ + rep->count = 1; + maybe_mutate (); +} + octave_value::octave_value (const DiagMatrix& d) : rep (new octave_matrix (d)) { @@ -489,6 +496,13 @@ maybe_mutate (); } +octave_value::octave_value (const ArrayN<Complex>& a) + : rep (new octave_complex_matrix (a)) +{ + rep->count = 1; + maybe_mutate (); +} + octave_value::octave_value (const ComplexDiagMatrix& d) : rep (new octave_complex_matrix (d)) {
--- a/src/ov.h +++ b/src/ov.h @@ -193,6 +193,7 @@ octave_value (const Cell& c, bool is_cs_list = false); octave_value (const Matrix& m); octave_value (const NDArray& nda); + octave_value (const ArrayN<double>& m); octave_value (const DiagMatrix& d); octave_value (const RowVector& v); octave_value (const ColumnVector& v);
--- a/src/pt-loop.cc +++ b/src/pt-loop.cc @@ -241,6 +241,41 @@ } \ while (0) +#define DO_ND_LOOP(arg) \ + do \ + { \ + int ndims = dv.length (); \ + Array<idx_vector> idx; \ + int steps = dv.numel () / dv (0); \ + idx.resize (ndims, idx_vector (1)); \ + idx (0) = idx_vector (':'); \ + \ + for (int i = 0; i < steps; i++) \ + { \ + MAYBE_DO_BREAKPOINT; \ + \ + octave_value val (arg.index(idx)); \ + \ + bool quit = false; \ + \ + do_for_loop_once (ult, val, quit); \ + quit = (i == steps - 1 ? true : quit); \ + \ + if (quit) \ + break; \ + \ + for (int j = 1; j < ndims; j++) \ + { \ + idx(j) = idx_vector (idx(j)(0) + 2); \ + if (idx(j)(0) < dv(j)) \ + break; \ + else \ + idx(j) = idx_vector (1); \ + } \ + } \ + } \ + while (0) + void tree_simple_for_command::eval (void) { @@ -332,42 +367,28 @@ } else if (rhs.is_matrix_type ()) { - Matrix m_tmp; - ComplexMatrix cm_tmp; - - int nr; - int steps; + NDArray m_tmp; + ComplexNDArray cm_tmp; + dim_vector dv; if (rhs.is_real_type ()) { - m_tmp = rhs.matrix_value (); - nr = m_tmp.rows (); - steps = m_tmp.columns (); + m_tmp = rhs.array_value (); + dv = m_tmp.dims (); } else { - cm_tmp = rhs.complex_matrix_value (); - nr = cm_tmp.rows (); - steps = cm_tmp.columns (); + cm_tmp = rhs.complex_array_value (); + dv = cm_tmp.dims (); } if (error_state) goto cleanup; if (rhs.is_real_type ()) - { - if (nr == 1) - DO_LOOP (m_tmp (0, i)); - else - DO_LOOP (m_tmp.extract (0, i, nr-1, i)); - } + DO_ND_LOOP(m_tmp); else - { - if (nr == 1) - DO_LOOP (cm_tmp (0, i)); - else - DO_LOOP (cm_tmp.extract (0, i, nr-1, i)); - } + DO_ND_LOOP(cm_tmp); } else if (rhs.is_map ()) { @@ -392,6 +413,12 @@ break; } } + else if (rhs.is_cell ()) + { + Cell c_tmp = rhs.cell_value (); + dim_vector dv = c_tmp.dims (); + DO_ND_LOOP(c_tmp); + } else { ::error ("invalid type in for loop expression near line %d, column %d",