# HG changeset patch # User jwe # Date 1069820919 0 # Node ID 7849788ca4bd8a63a00a2829df33614bc0cb6096 # Parent e6260247a166e4d5f9389da78c3dcbb5dc8df65e [project @ 2003-11-26 04:28:39 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,29 @@ +2003-11-25 John W. Eaton + + * ov-str-mat.cc (CHAR_MATRIX_CONV): New macro. + * ov-str-mat.h (octave_char_matrix_str::double_value, + octave_char_matrix_str::matrix_value, + octave_char_matrix_str::array_value, + octave_char_matrix_str::complex_value, + octave_char_matrix_str::complex_matrix_value, + (octave_char_matrix_str::complex_array_value): Use it. + + * ov-bool-mat.cc (default_numeric_conversion_function): + Convert to NDArray, not Matrix. + * ov-str-mat.cc (default_numeric_conversion_function): Likewise. + + * ov-range.h (octave_range::array_value): New function. + (octave_range::complex_array_value): Likewise. + * ov-ch-mat.h (charNDArray::array_value): New function. + (charNDArray::complex_array_value): Likewise. + * ov-str-mat.h (octave_char_matrix_str::array_value): Likewise. + (octave_char_matrix_str::complex_value): Likewise. + (octave_char_matrix_str::complex_matrix_value): Likewise. + (octave_char_matrix_str::complex_array_value): Likewise. + + * mappers.cc (acosh, log, log10, sqrt): + Use octave_Inf instead of DBL_MAX for range limit. + 2003-11-24 John W. Eaton * version.h (OCTAVE_VERSION): Now 2.1.52. diff --git a/src/defun.h b/src/defun.h --- a/src/defun.h +++ b/src/defun.h @@ -128,11 +128,11 @@ // c_c_map is a pointer to a function that should be called for // complex arguments that are expected to create complex results. // -// lo is the lower bound of the range for which real arguments can -// become complex. (e.g., lo == -Inf for sqrt). +// lo is the lower bound of the range for which real arguments +// return real results (e.g., lo == 0 for sqrt). // -// hi is the upper bound of the range for which real arguments can -// become complex. (e.g., hi == 0 for sqrt). +// hi is the upper bound of the range for which real arguments +// return real results (e.g., hi == Inf for sqrt). // // ch_map_flag has the following meanings for the ch_map function: // diff --git a/src/mappers.cc b/src/mappers.cc --- a/src/mappers.cc +++ b/src/mappers.cc @@ -197,7 +197,7 @@ Compute the inverse cosine of each element of @var{x}.\n\ @end deftypefn"); - DEFUN_MAPPER (acosh, 0, 0, 0, acosh, 0, acosh, 1.0, DBL_MAX, 0, 1, + DEFUN_MAPPER (acosh, 0, 0, 0, acosh, 0, acosh, 1.0, octave_Inf, 0, 1, "-*- texinfo -*-\n\ @deftypefn {Mapping Function} {} acosh (@var{x})\n\ Compute the inverse hyperbolic cosine of each element of @var{x}.\n\ @@ -543,7 +543,7 @@ @end deftypefn\n\ @seealso{gamma and gammai}"); - DEFUN_MAPPER (log, 0, 0, 0, log, 0, log, 0.0, DBL_MAX, 0, 1, + DEFUN_MAPPER (log, 0, 0, 0, log, 0, log, 0.0, octave_Inf, 0, 1, "-*- texinfo -*-\n\ @deftypefn {Mapping Function} {} log (@var{x})\n\ Compute the natural logarithm for each element of @var{x}. To compute the\n\ @@ -551,7 +551,7 @@ @end deftypefn\n\ @seealso{log2, log10, logspace, and exp}"); - DEFUN_MAPPER (log10, 0, 0, 0, log10, 0, log10, 0.0, DBL_MAX, 0, 1, + DEFUN_MAPPER (log10, 0, 0, 0, log10, 0, log10, 0.0, octave_Inf, 0, 1, "-*- texinfo -*-\n\ @deftypefn {Mapping Function} {} log10 (@var{x})\n\ Compute the base-10 logarithm for each element of @var{x}.\n\ @@ -608,7 +608,7 @@ Compute the inverse hyperbolic sin of each element of @var{x}.\n\ @end deftypefn"); - DEFUN_MAPPER (sqrt, 0, 0, 0, sqrt, 0, sqrt, 0.0, DBL_MAX, 0, 1, + DEFUN_MAPPER (sqrt, 0, 0, 0, sqrt, 0, sqrt, 0.0, octave_Inf, 0, 1, "-*- texinfo -*-\n\ @deftypefn {Mapping Function} {} sqrt (@var{x})\n\ Compute the square root of @var{x}. If @var{x} is negative, a complex\n\ diff --git a/src/ov-bool-mat.cc b/src/ov-bool-mat.cc --- a/src/ov-bool-mat.cc +++ b/src/ov-bool-mat.cc @@ -56,7 +56,7 @@ { CAST_CONV_ARG (const octave_bool_matrix&); - return new octave_matrix (Matrix (v.bool_matrix_value ())); + return new octave_matrix (NDArray (v.bool_array_value ())); } type_conv_fcn diff --git a/src/ov-ch-mat.h b/src/ov-ch-mat.h --- a/src/ov-ch-mat.h +++ b/src/ov-ch-mat.h @@ -98,11 +98,17 @@ Matrix matrix_value (bool = false) const { return Matrix (matrix.matrix_value ()); } + NDArray array_value (bool = false) const + { return NDArray (matrix); } + Complex complex_value (bool = false) const; ComplexMatrix complex_matrix_value (bool = false) const { return ComplexMatrix (matrix.matrix_value ()); } + ComplexNDArray complex_array_value (bool = false) const + { return ComplexNDArray (matrix); } + charMatrix char_matrix_value (bool = false) const { return matrix.matrix_value (); } diff --git a/src/ov-range.h b/src/ov-range.h --- a/src/ov-range.h +++ b/src/ov-range.h @@ -150,11 +150,17 @@ Matrix matrix_value (bool = false) const { return range.matrix_value (); } + NDArray array_value (bool = false) const + { return range.matrix_value (); } + Complex complex_value (bool = false) const; ComplexMatrix complex_matrix_value (bool = false) const { return ComplexMatrix (range.matrix_value ()); } + ComplexNDArray complex_array_value (bool = false) const + { return ComplexMatrix (range.matrix_value ()); } + Range range_value (void) const { return range; } octave_value convert_to_str_internal (bool pad, bool force) const; diff --git a/src/ov-str-mat.cc b/src/ov-str-mat.cc --- a/src/ov-str-mat.cc +++ b/src/ov-str-mat.cc @@ -50,9 +50,9 @@ { CAST_CONV_ARG (const octave_char_matrix_str&); - Matrix m = v.matrix_value (true); + NDArray nda = v.array_value (true); - return error_state ? 0 : new octave_matrix (m); + return error_state ? 0 : new octave_matrix (nda); } type_conv_fcn @@ -131,40 +131,56 @@ return retval; } +#define CHAR_MATRIX_CONV(T, INIT, TNAME, FCN) \ + T retval INIT; \ + \ + if (! force_string_conv) \ + gripe_invalid_conversion ("string", TNAME); \ + else \ + { \ + if (Vwarn_str_to_num) \ + gripe_implicit_conversion ("string", TNAME); \ + \ + retval = octave_char_matrix::FCN (); \ + } \ + \ + return retval + double octave_char_matrix_str::double_value (bool force_string_conv) const { - double retval = 0; + CHAR_MATRIX_CONV (double, = 0, "real scalar", double_value); +} - if (! force_string_conv) - gripe_invalid_conversion ("string", "real scalar"); - else - { - if (Vwarn_str_to_num) - gripe_implicit_conversion ("string", "real scalar"); - - retval = octave_char_matrix::double_value (); - } - - return retval; +Complex +octave_char_matrix_str::complex_value (bool force_string_conv) const +{ + CHAR_MATRIX_CONV (Complex, = 0, "complex scalar", complex_value); } Matrix octave_char_matrix_str::matrix_value (bool force_string_conv) const { - Matrix retval; + CHAR_MATRIX_CONV (Matrix, , "real matrix", matrix_value); +} + +ComplexMatrix +octave_char_matrix_str::complex_matrix_value (bool force_string_conv) const +{ + CHAR_MATRIX_CONV (ComplexMatrix, , "complex matrix", complex_matrix_value); +} - if (! force_string_conv) - gripe_invalid_conversion ("string", "real matrix"); - else - { - if (Vwarn_str_to_num) - gripe_implicit_conversion ("string", "real matrix"); +NDArray +octave_char_matrix_str::array_value (bool force_string_conv) const +{ + CHAR_MATRIX_CONV (NDArray, , "real N-d array", array_value); +} - retval = octave_char_matrix::matrix_value (); - } - - return retval; +ComplexNDArray +octave_char_matrix_str::complex_array_value (bool force_string_conv) const +{ + CHAR_MATRIX_CONV (ComplexNDArray, , "complex N-d array", + complex_array_value); } string_vector diff --git a/src/ov-str-mat.h b/src/ov-str-mat.h --- a/src/ov-str-mat.h +++ b/src/ov-str-mat.h @@ -108,6 +108,14 @@ Matrix matrix_value (bool = false) const; + NDArray array_value (bool = false) const; + + Complex complex_value (bool = false) const; + + ComplexMatrix complex_matrix_value (bool = false) const; + + ComplexNDArray complex_array_value (bool = false) const; + string_vector all_strings (bool pad = false, bool force = false) const; std::string string_value (bool force = false) const;