changeset 24587:6ece7c7e4912

tolower/toupper functions return complex numbers unchanged (bug #52380). * mappers.cc (Ftolower, Ftoupper): Add BIST tests for new behavior. * ov-complex.cc (octave_complex::map): Directly return input for cases of umap_xtolower and umap_xtoupper. * ov-cx-mat.cc (octave_complex_matrix::map): Directly return input for cases of umap_xtolower and umap_xtoupper. * ov-flt-complex.cc (octave_float_complex::map): Directly return input for cases of umap_xtolower and umap_xtoupper. * ov-flt-cx-mat.cc (octave_float_complex_matrix::map): Directly return input for cases of umap_xtolower and umap_xtoupper.
author Stevie Schraudner <stevietodd@hotmail.com>
date Wed, 10 Jan 2018 17:50:13 -0500
parents c24b536df5d4
children c12b5cec5c6c
files libinterp/corefcn/mappers.cc libinterp/octave-value/ov-complex.cc libinterp/octave-value/ov-cx-mat.cc libinterp/octave-value/ov-flt-complex.cc libinterp/octave-value/ov-flt-cx-mat.cc
diffstat 5 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/mappers.cc	Thu Jan 11 20:30:08 2018 +0100
+++ b/libinterp/corefcn/mappers.cc	Wed Jan 10 17:50:13 2018 -0500
@@ -2176,6 +2176,11 @@
 %!assert (tolower ({["ABC"; "DEF"]}), {["abc";"def"]})
 %!assert (tolower (68), 68)
 %!assert (tolower ({[68, 68; 68, 68]}), {[68, 68; 68, 68]})
+%!assert (tolower (68i), 68i)
+%!assert (tolower ({[68i, 68; 68, 68i]}), {[68i, 68; 68, 68i]})
+%!assert (tolower (single (68i)), single (68i))
+%!assert (tolower ({single([68i, 68; 68, 68i])}), {single([68i, 68; 68, 68i])})
+
 %!test
 %! classes = {@char, @double, @single, ...
 %!            @int8, @int16, @int32, @int64, ...
@@ -2235,6 +2240,12 @@
 %!assert (toupper ({["abc"; "def"]}), {["ABC";"DEF"]})
 %!assert (toupper (100), 100)
 %!assert (toupper ({[100, 100; 100, 100]}), {[100, 100; 100, 100]})
+%!assert (toupper (100i), 100i)
+%!assert (toupper ({[100i, 100; 100, 100i]}), {[100i, 100; 100, 100i]})
+%!assert (toupper (single (100i)), single (100i))
+%!assert (toupper ({single([100i, 100; 100, 100i])}),
+%!                 {single([100i, 100; 100, 100i])})
+
 %!test
 %! classes = {@char, @double, @single, ...
 %!            @int8, @int16, @int32, @int64, ...
--- a/libinterp/octave-value/ov-complex.cc	Thu Jan 11 20:30:08 2018 +0100
+++ b/libinterp/octave-value/ov-complex.cc	Wed Jan 10 17:50:13 2018 -0500
@@ -526,6 +526,11 @@
     SCALAR_MAPPER (isna, octave::math::isna);
     SCALAR_MAPPER (isnan, octave::math::isnan);
 
+    // Special cases for Matlab compatibility.
+    case umap_xtolower:
+    case umap_xtoupper:
+      return scalar;
+
     default:
       return octave_base_value::map (umap);
     }
--- a/libinterp/octave-value/ov-cx-mat.cc	Thu Jan 11 20:30:08 2018 +0100
+++ b/libinterp/octave-value/ov-cx-mat.cc	Wed Jan 10 17:50:13 2018 -0500
@@ -754,6 +754,11 @@
     case umap_conj:
       return ::conj (matrix);
 
+    // Special cases for Matlab compatibility.
+    case umap_xtolower:
+    case umap_xtoupper:
+      return matrix;
+
 #define ARRAY_METHOD_MAPPER(UMAP, FCN)        \
     case umap_ ## UMAP:                       \
       return octave_value (matrix.FCN ())
--- a/libinterp/octave-value/ov-flt-complex.cc	Thu Jan 11 20:30:08 2018 +0100
+++ b/libinterp/octave-value/ov-flt-complex.cc	Wed Jan 10 17:50:13 2018 -0500
@@ -474,6 +474,11 @@
     SCALAR_MAPPER (isna, octave::math::isna);
     SCALAR_MAPPER (isnan, octave::math::isnan);
 
+    // Special cases for Matlab compatibility
+    case umap_xtolower:
+    case umap_xtoupper:
+      return scalar;
+
     default:
       return octave_base_value::map (umap);
     }
--- a/libinterp/octave-value/ov-flt-cx-mat.cc	Thu Jan 11 20:30:08 2018 +0100
+++ b/libinterp/octave-value/ov-flt-cx-mat.cc	Wed Jan 10 17:50:13 2018 -0500
@@ -706,6 +706,11 @@
     case umap_conj:
       return ::conj (matrix);
 
+    // Special cases for Matlab compatibility.
+    case umap_xtolower:
+    case umap_xtoupper:
+      return matrix;
+               
 #define ARRAY_METHOD_MAPPER(UMAP, FCN)        \
     case umap_ ## UMAP:                       \
       return octave_value (matrix.FCN ())