# HG changeset patch # User John W. Eaton # Date 1524162808 14400 # Node ID c1e344166c4be209289285cf011b39fcaeb84c1d # Parent 9b059a36a1ae75c8da513f8a90cc2e2d8f8374a5# Parent f692728de1133dc905ae1eb256c9f933480d1c25 maint: Merge stable to default. diff -r 9b059a36a1ae -r c1e344166c4b libinterp/corefcn/data.cc --- a/libinterp/corefcn/data.cc Thu Apr 19 02:00:04 2018 -0400 +++ b/libinterp/corefcn/data.cc Thu Apr 19 14:33:28 2018 -0400 @@ -2858,9 +2858,11 @@ If @var{dim} is omitted, it defaults to the first non-singleton dimension. The optional @qcode{"type"} input determines the class of the variable -used for calculations. If the argument @qcode{"native"} is given, then -the operation is performed in the same type as the original argument, rather -than the default double type. +used for calculations. By default, operations on floating point inputs (double +or single) are performed in their native data type, while operations on +integer, logical, and character data types are performed using doubles. If the +argument @qcode{"native"} is given, then the operation is performed in the same +type as the original argument. For example: @@ -2873,13 +2875,13 @@ @end group @end example -On the contrary, if @qcode{"double"} is given, the sum is performed in -double precision even for single precision inputs. +If @qcode{"double"} is given the sum is performed in double precision even for +single precision inputs. For double precision inputs, the @qcode{"extra"} option will use a more accurate algorithm than straightforward summation. For single precision -inputs, @qcode{"extra"} is the same as @qcode{"double"}. Otherwise, -@qcode{"extra"} has no effect. +inputs, @qcode{"extra"} is the same as @qcode{"double"}. For all other data +type @qcode{"extra"} has no effect. @seealso{cumsum, sumsq, prod} @end deftypefn */) { diff -r 9b059a36a1ae -r c1e344166c4b libinterp/octave-value/ov-lazy-idx.cc --- a/libinterp/octave-value/ov-lazy-idx.cc Thu Apr 19 02:00:04 2018 -0400 +++ b/libinterp/octave-value/ov-lazy-idx.cc Thu Apr 19 14:33:28 2018 -0400 @@ -157,6 +157,66 @@ return index.as_array ().is_sorted_rows (mode); } +octave_value +octave_lazy_index::as_double (void) const +{ + return array_value (); +} + +octave_value +octave_lazy_index::as_single (void) const +{ + return float_array_value (); +} + +octave_value +octave_lazy_index::as_int8 (void) const +{ + return int8_array_value (); +} + +octave_value +octave_lazy_index::as_int16 (void) const +{ + return int16_array_value (); +} + +octave_value +octave_lazy_index::as_int32 (void) const +{ + return int32_array_value (); +} + +octave_value +octave_lazy_index::as_int64 (void) const +{ + return int64_array_value (); +} + +octave_value +octave_lazy_index::as_uint8 (void) const +{ + return uint8_array_value (); +} + +octave_value +octave_lazy_index::as_uint16 (void) const +{ + return uint16_array_value (); +} + +octave_value +octave_lazy_index::as_uint32 (void) const +{ + return uint32_array_value (); +} + +octave_value +octave_lazy_index::as_uint64 (void) const +{ + return uint64_array_value (); +} + static const std::string value_save_tag ("index_value"); bool octave_lazy_index::save_ascii (std::ostream& os) @@ -197,3 +257,20 @@ return true; } + +/* +%!shared x, y +%! x = find ([-1, 0, -2, 1, 3, -4] < 0); +%! y = [1, 3, 6]; +%!assert (typeinfo (x), "lazy_index") +%!assert (double (x), y) +%!assert (single (x), single (y)) +%!assert (int8 (x), int8 (y)) +%!assert (int16 (x), int16 (y)) +%!assert (int32 (x), int32 (y)) +%!assert (int64 (x), int64 (y)) +%!assert (uint8 (x), uint8 (y)) +%!assert (uint16 (x), uint16 (y)) +%!assert (uint32 (x), uint32 (y)) +%!assert (uint64 (x), uint64 (y)) +*/ diff -r 9b059a36a1ae -r c1e344166c4b libinterp/octave-value/ov-lazy-idx.h --- a/libinterp/octave-value/ov-lazy-idx.h Thu Apr 19 02:00:04 2018 -0400 +++ b/libinterp/octave-value/ov-lazy-idx.h Thu Apr 19 14:33:28 2018 -0400 @@ -187,6 +187,19 @@ return make_value ().convert_to_str_internal (pad, force, type); } + octave_value as_double (void) const; + octave_value as_single (void) const; + + octave_value as_int8 (void) const; + octave_value as_int16 (void) const; + octave_value as_int32 (void) const; + octave_value as_int64 (void) const; + + octave_value as_uint8 (void) const; + octave_value as_uint16 (void) const; + octave_value as_uint32 (void) const; + octave_value as_uint64 (void) const; + void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const { return make_value ().print_raw (os, pr_as_read_syntax);