Sum of elements along dimension dim.
If dim is omitted, it defaults to the first non-singleton dimension.
"type" input determines the class of the variable
used for calculations. If the argument
"native" is given, then
the operation is performed in the same type as the original argument, rather
than the default double type.
sum ([true, true]) ⇒ 2 sum ([true, true], "native") ⇒ true
On the contrary, if
"double" is given, the sum is performed in
double precision even for single precision inputs.
For double precision inputs, the
"extra" option will use a more
accurate algorithm than straightforward summation. For single precision
"extra" is the same as
"extra" has no effect.
See also: cumsum, sumsq, prod.