comparison libinterp/octave-value/ov-base-sparse.cc @ 18195:1b6db9303933

allow toupper and tolower to handle numeric values (bug #33537) * ov-base-sparse.cc (octave_base_sparse<T>::map): Special case for umap_xtolower and umap_xtoupper. * ov-float.cc (octave_float_scalar::map): Likewise. * ov-flt-re-mat.cc (octave_float_matrix::map): Likewise. * ov-intx.h (OCTAVE_VALUE_INT_MATRIX_T::map, OCTAVE_VALUE_INT_SCALAR_T::map): Likewise. * ov-re-mat.cc (octave_matrix::map): Likewise. * ov-scalar.cc (octave_scalar::map): Likewise. * build-sparse-tests.sh, mappers.cc: Update tests.
author John W. Eaton <jwe@octave.org>
date Thu, 02 Jan 2014 22:44:37 -0500
parents f1b59ef34eda
children 0d5721873d6b
comparison
equal deleted inserted replaced
18194:1461b9cfac4e 18195:1b6db9303933
438 438
439 template <class T> 439 template <class T>
440 octave_value 440 octave_value
441 octave_base_sparse<T>::map (octave_base_value::unary_mapper_t umap) const 441 octave_base_sparse<T>::map (octave_base_value::unary_mapper_t umap) const
442 { 442 {
443 if (umap == umap_xtolower || umap == umap_xtoupper)
444 return matrix;
445
443 // Try the map on the dense value. 446 // Try the map on the dense value.
447 // FIXME: We should probably be smarter about this, especially for the
448 // cases that are expected to return sparse matrices.
444 octave_value retval = this->full_value ().map (umap); 449 octave_value retval = this->full_value ().map (umap);
445 450
446 // Sparsify the result if possible. 451 // Sparsify the result if possible.
452
447 // FIXME: intentionally skip this step for string mappers. Is this wanted? 453 // FIXME: intentionally skip this step for string mappers. Is this wanted?
454 // FIXME: this will break if some well-meaning person rearranges the
455 // enum list in ov-base.h.
448 if (umap >= umap_xisalnum && umap <= umap_xtoupper) 456 if (umap >= umap_xisalnum && umap <= umap_xtoupper)
449 return retval; 457 return retval;
450 458
451 switch (retval.builtin_type ()) 459 switch (retval.builtin_type ())
452 { 460 {