Ben Abbott wrote:
I've encountered a problem with the internal function sum(), using
2.9.16
The test below produces the correct result
sum ([true, false])
ans = 1
The result is *not* logical (which is consistent with Matlab).
islogical (sum ([true, false]))
ans = 0
However, when asked to return the result in the native format of the
inputs (as Matlab does) ...
islogical (sum ([true, false], 'native'))
error: invalid conversion from string to real scalar
error: octave_base_value::int_value (): wrong type argument
`sq_string'
error: evaluating argument list element number 1
The "native" argument is not implemented and so what is happening
above
is that the argument 'native' is taken as defining the dimension along
which to add the values..
While Matlab produces this result ans=1, which is consistent with
Octave when the test is modified as ...
islogical (logical (sum ([true, false])))
ans = 1
When the arguments to sum are characters and accompanied by 'native',
Matlab produces an error.
I'm not up to c++ programing. So I will not be any help in modifying
the internal function, sum ().
I don't see why matlab should produce an error here.. Adding character
values should be legal, though perhaps a dumb thing to do.. Equally I
don't see why matlab chose to limit this argument only to the "sum"
function and not also include the "cumsum", "prod", etc functions as
well. In any case consider the attached patch that adds this
functionality to "sum".. Perhaps the other data reduction operators
should also include this functionality?