From bug-octave-request at octave dot org Wed Apr 21 07:14:34 2004 Subject: Fix for max([1,2]) bug in CVS From: David Bateman To: bug at octave dot org Date: Wed, 21 Apr 2004 14:10:17 +0200 --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline It seems I didn't check the case of a single vector argument to min and max in the changes I made previous. Therefore min([1,2]) gives an incorrect result in the CVS. The attached patch address this problem. The ChangeLog entry is * DLD-FUNCTIONS/minmax.cc: correct bug for single vector argument Regards David -- David Bateman David dot Bateman at motorola dot com Motorola CRM +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.minmax" *** src/DLD-FUNCTIONS/minmax.cc.orig2 2004-04-21 14:02:32.000000000 +0200 --- src/DLD-FUNCTIONS/minmax.cc 2004-04-21 14:02:40.000000000 +0200 *************** *** 100,119 **** \ bool single_arg = (nargin == 1) || arg2.is_empty(); \ \ - if (single_arg) \ - { \ - dv(dim) = 1; \ - int n_dims = dv.length (); \ - for (int i = n_dims; i > 1; i--) \ - { \ - if (dv(i-1) == 1) \ - n_dims--; \ - else \ - break; \ - } \ - dv.resize (n_dims); \ - } \ - \ if (single_arg && (nargout == 1 || nargout == 0)) \ { \ if (arg1.is_real_type ()) \ --- 100,105 ---- *************** *** 123,129 **** if (! error_state) \ { \ NDArray n = m. FCN (dim); \ - n.resize (dv); \ retval(0) = n; \ } \ } \ --- 109,114 ---- *************** *** 134,140 **** if (! error_state) \ { \ ComplexNDArray n = m. FCN (dim); \ - n.resize (dv); \ retval(0) = n; \ } \ } \ --- 119,124 ---- *************** *** 152,158 **** if (! error_state) \ { \ NDArray n = m. FCN (index, dim); \ - n.resize (dv); \ retval(0) = n; \ } \ } \ --- 136,141 ---- *************** *** 163,169 **** if (! error_state) \ { \ ComplexNDArray n = m. FCN (index, dim); \ - n.resize (dv); \ retval(0) = n; \ } \ } \ --- 146,151 ---- --WIyZ46R2i8wDzkSu-- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------