Wed 26 Oct 2011 04:19:13 AM UTC, comment #10:
I know this seems confusing, but this definition of array is just the way Matlab and Octave work.
Unfortunately, the docstring for arrayfun can't be changed to say "numerical array" because "numeric" has a very specific meaning in Octave. See the documentaion for isnumeric
Changing arrayfun to say that it operates on numerical arrays would imply that it does not work on logical or character arrays. This is not the case.
|
Wed 12 Oct 2011 01:54:35 PM UTC, comment #9:
To make it concrete
> accumarray(1,1)
ans = 1
octave:61> accumarray(1,@sin)
error: accumarray: wrong type argument `function handle'
>isvector(@sin)
ans = 1
> help accumarray
Create an array by accumulating the elements of a *vector* into the positions defined by their subscripts. The subscripts are defined by the rows of the matrix SUBS and the values by VALS.
Do you see what I mean?
|
Wed 12 Oct 2011 01:44:33 PM UTC, comment #8:
I see.
So accepting Array is an N-d (with N>=2) collection of object that can be indexed. Then docstring of accumarray and arrayfun should be corrected to say they work on "numerical arrays".
arrayfun.m:
"Execute a function on each element of an array" --> "Execute a function on each element of a numerical array"
accumarray.m:
"Create an array by accumulating the elements of a vector into the positions defined by their subscripts." --> "Create an numerical array by accumulating the elements of a numerical vector into the positions defined by their subscripts."
But I guess "numerical array" is equivalent to "matrix" and "numerical vector" is equivalent to "row matrix" or "column matrix".
|
Wed 12 Oct 2011 01:36:46 PM UTC, comment #7:
You can also store function handles in struct arrays.
Not all functions work on all types.
The current doc string says:
Return true if X is a vector. A vector is a 2-D array where one of the dimensions is equal to 1. As a consequence a 1x1 array, or scalar, is also a vector.
I think you have a different idea of what "array" means than I do. In Octave, an array is just an N-d (with N >= 2) collection of objects that can be indexed. Array does not necessarily imply a numeric object. If it did, we would not have "cell arrays".
So I don't really see any bug to fix here.
|
Wed 12 Oct 2011 01:11:08 PM UTC, comment #6:
Then imho, the docstring of isvector should say
"A vector is a 2-D arrangement of octave types where one of the dimensions is equal to one"
and not use the word "Array" since it has a very clear meaning like in arrayfun.
also accumarray will not work is the "vector" argument (according to its docstring) is a cell. Therefore there it seems a cell (only container for function handles that I knwon) is not a vector.
|
Wed 12 Oct 2011 01:09:24 PM UTC, comment #5:
Every object in Octave has a minimum of two dimensions.
Anything that is 1xN or Nx1 is a vector, including objects whose dimensions are 1x1.
is not valid because you can't concatenate function handle objects. They can only be 1x1.
|
Wed 12 Oct 2011 01:02:12 PM UTC, comment #4:
Matlab gives me
>> isvector (@sin)
ans =
1
Søren
|
Wed 12 Oct 2011 12:58:16 PM UTC, comment #3:
Ok, then the docstring should be more specific and say
"As a consequence a 1x1 array, or scalar, or function_hanlde is also a vector."
Since the default vectors and scalars are numeric and because the following is not valid
[@ischar; @isvector]
Are cells also arrays?
Since isvector(cell(1,N)) or isvector(cell(N,1)) also gives true and the docstring of isvectors says
"A vector is a 2-D array"
|
Wed 12 Oct 2011 12:49:10 PM UTC, comment #2:
But
is 1, so it is a scalar and a vector, just not a numeric one.
WDMD?
|
Wed 12 Oct 2011 12:43:16 PM UTC, comment #1:
Same applies to function isscalar
|
Wed 12 Oct 2011 12:40:16 PM UTC, original submission:
Hi the following code fails.
a=@(x) ischar (x);
assert ( !isvector (a) );
It shouldn't. (checked in 3.4.3-rc0 and dev changeset: 1e12601d2697, tag:tip)
Thanks
|