[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #59191] Using (end+1) on an empty matrix refer
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #59191] Using (end+1) on an empty matrix refers causes unexpected padding with zeros |
Date: |
Sun, 27 Sep 2020 10:00:13 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0 |
URL:
<https://savannah.gnu.org/bugs/?59191>
Summary: Using (end+1) on an empty matrix refers causes
unexpected padding with zeros
Project: GNU Octave
Submitted by: None
Submitted on: Sun 27 Sep 2020 02:00:12 PM UTC
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Inaccurate Result
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Release: dev
Discussion Lock: Any
Operating System: GNU/Linux
_______________________________________________________
Details:
Octave version 7.0.0 with hg id 901a92f45ff0 on 64-bit Linux
When augmenting an array by using (end+1) as the subscript on an lvalue, it
works properly for one or two dimensions, but for three or more dimensions it
causes the array to be unexpectedly pre-padded with an extra layer of zeros.
It appears that (end+1) for an empty matrix refers to subscript value 1 for
one and two dimensions, but subscript value 2 for three or more dimensions.
Once this behavior is known, it can certainly be worked around by the user. It
is being reported in case the behavior was not intended.
octave:7> lst = []; lst(end+1,:) = pi(1,4), size(lst)
lst =
3.1416 3.1416 3.1416 3.1416
ans =
1 4
octave:8> lst = []; lst(:,end+1) = pi(1,4), size(lst)
lst =
3.1416
3.1416
3.1416
3.1416
ans =
4 1
octave:9> lst = []; lst(:,:,end+1) = pi(4,4), size(lst)
lst =
ans(:,:,1) =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
ans(:,:,2) =
3.1416 3.1416 3.1416 3.1416
3.1416 3.1416 3.1416 3.1416
3.1416 3.1416 3.1416 3.1416
3.1416 3.1416 3.1416 3.1416
ans =
4 4 2
octave:10> lst = []; lst(:,:,:,end+1) = pi(4,4), size(lst)
lst =
ans(:,:,1,1) =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
ans(:,:,1,2) =
3.1416 3.1416 3.1416 3.1416
3.1416 3.1416 3.1416 3.1416
3.1416 3.1416 3.1416 3.1416
3.1416 3.1416 3.1416 3.1416
ans =
4 4 1 2
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?59191>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #59191] Using (end+1) on an empty matrix refers causes unexpected padding with zeros,
anonymous <=