Mercurial > octave
comparison libinterp/corefcn/data.cc @ 25286:44c0aca121cc stable
doc: Clarify docstring for sum (bug #53698).
* data.cc: Provide a better explanation of "native" argument and what happens
when it is not present.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 19 Apr 2018 08:39:45 -0700 |
parents | 078b795c5219 |
children | c1e344166c4b e0906c38f18e |
comparison
equal
deleted
inserted
replaced
25284:78fb24bdd8bb | 25286:44c0aca121cc |
---|---|
2856 Sum of elements along dimension @var{dim}. | 2856 Sum of elements along dimension @var{dim}. |
2857 | 2857 |
2858 If @var{dim} is omitted, it defaults to the first non-singleton dimension. | 2858 If @var{dim} is omitted, it defaults to the first non-singleton dimension. |
2859 | 2859 |
2860 The optional @qcode{"type"} input determines the class of the variable | 2860 The optional @qcode{"type"} input determines the class of the variable |
2861 used for calculations. If the argument @qcode{"native"} is given, then | 2861 used for calculations. By default, operations on floating point inputs (double |
2862 the operation is performed in the same type as the original argument, rather | 2862 or single) are performed in their native data type, while operations on |
2863 than the default double type. | 2863 integer, logical, and character data types are performed using doubles. If the |
2864 argument @qcode{"native"} is given, then the operation is performed in the same | |
2865 type as the original argument. | |
2864 | 2866 |
2865 For example: | 2867 For example: |
2866 | 2868 |
2867 @example | 2869 @example |
2868 @group | 2870 @group |
2871 sum ([true, true], "native") | 2873 sum ([true, true], "native") |
2872 @result{} true | 2874 @result{} true |
2873 @end group | 2875 @end group |
2874 @end example | 2876 @end example |
2875 | 2877 |
2876 On the contrary, if @qcode{"double"} is given, the sum is performed in | 2878 If @qcode{"double"} is given the sum is performed in double precision even for |
2877 double precision even for single precision inputs. | 2879 single precision inputs. |
2878 | 2880 |
2879 For double precision inputs, the @qcode{"extra"} option will use a more | 2881 For double precision inputs, the @qcode{"extra"} option will use a more |
2880 accurate algorithm than straightforward summation. For single precision | 2882 accurate algorithm than straightforward summation. For single precision |
2881 inputs, @qcode{"extra"} is the same as @qcode{"double"}. Otherwise, | 2883 inputs, @qcode{"extra"} is the same as @qcode{"double"}. For all other data |
2882 @qcode{"extra"} has no effect. | 2884 type @qcode{"extra"} has no effect. |
2883 @seealso{cumsum, sumsq, prod} | 2885 @seealso{cumsum, sumsq, prod} |
2884 @end deftypefn */) | 2886 @end deftypefn */) |
2885 { | 2887 { |
2886 int nargin = args.length (); | 2888 int nargin = args.length (); |
2887 | 2889 |