octave-bug-tracker
[Top][All Lists]

## [Octave-bug-tracker] [bug #52723] unexpected space in matrix expression

 From: anonymous Subject: [Octave-bug-tracker] [bug #52723] unexpected space in matrix expression (brackets) in document Date: Thu, 21 Dec 2017 23:26:05 -0500 (EST) User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

```Follow-up Comment #1, bug #52723 (project octave):

Section 8.1.1 Advanced Indexing, paragraph 2:

For the ordinary and most common case, ‘m == n’, and each index
corresponds to its respective dimension.  If ‘m < n’ and every index is
less than the size of the array in the i^{th} dimension, ‘m(i) < n(i)’,
then the index expression is padded with trailing singleton dimensions
(‘[ones (m-n, 1)]’).  If ‘m < n’ but one of the indices ‘m(i)’ is
outside the size of the current array, then the last ‘n-m+1’ dimensions
are folded into a single dimension with an extent equal to the product
of extents of the original dimensions.  This is easiest to understand
with an example.

1.
"ones(m-n, 1)" should be "ones(n-m, 1)" since m < n.
2.
It seems that "ones(n-m, 1)" is not necessary to be put into "[ ]"
since an index expression is a cs-list rather than a vector.
3.
It seems that the symbol 'm' and 'n' have been reused.
Standalone 'm' means the number of indices and 'n' means 'ndims(a)',
but in 'm(i)' 'n(i)', 'm' means the whole indices and 'n' means 'size(a)'.
4.
If m < n, not any one of the indices 'm(i)' but only the last index 'm(end)'
can be outside the size.
For example, if 'a = reshape(1:8,2,2,2)', then 'a(4,_)' is not allowd but
'a(_,4)' is allowed.

octave:2>  a
a =

ans(:,:,1) =

1   3
2   4

ans(:,:,2) =

5   7
6   8

octave:3>  a(2,4)
ans =  8
octave:4>  a(4,2)
error: a(4,_): out of bound 2

I try to rephase the paragraph as follow:

For the ordinary and most common case, ‘m == n’, and each index
corresponds to its respective dimension.  If ‘m < n’ and every index is
less than the size of the array in the i^{th} dimension, then the index
expression is padded with ‘n-m’ trailing singleton dimensions.
If ‘m < n’ but the last index is outside the size of the current array,
then the last ‘n-m+1’ dimensions are folded into a single dimension with
an extent equal to the product of extents of the original dimensions.
This is easiest to understand with an example.

and a more neat version:

For the ordinary and most common case, ‘m == n’, and each index
corresponds to its respective dimension.  If ‘m < n’, then the last
‘n-m+1’ dimensions are folded into a single dimension with an extent
equal to the product of extents of the original dimensions.  This is
easiest to understand with an example.

_______________________________________________________

<http://savannah.gnu.org/bugs/?52723>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/

```