[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
extracting rows from empty matrix
From: |
John W. Eaton |
Subject: |
extracting rows from empty matrix |
Date: |
Tue, 14 Apr 1998 15:09:38 -0500 (CDT) |
On 11-Apr-1998, Stef Pillaert <address@hidden> wrote:
| it seems that it's not allowed to extract a row from an empty matrix, or am
| I wrong?
|
| octave:1> test=zeros(2,0)
| test = [](2x0)
| octave:2> A= test(1,:)
| error: invalid column index = 0
| error: evaluating index expression near line 2, column 1
|
| Would it be against the rules of working with empty matrices if this gave:
|
| A = [](1x0)
|
| or are actions like this too 'dangerous' (because what to do with something
| like test(1,0), would it be [](1x0) also?)
|
| (The reason I'm asking this, is that I do something like
|
| matrix_1(1,:)=[matrix_2(1,:),matrix_3(1,:)]
|
| where matrix_3 might sometimes be an [](2x0) matrix, and sometimes it is
| not.).
|
| Any comments?
It looks like a bug to me. Please try the following patch.
Thanks,
jwe
Tue Apr 14 14:41:30 1998 John W. Eaton <address@hidden>
* Array2-idx.h (index): Allow x = zeros (2, 0); x(1,:) to work.
*** liboctave/Array2-idx.h~ Mon Jan 19 16:23:37 1998
--- liboctave/Array2-idx.h Tue Apr 14 14:59:58 1998
***************
*** 173,178 ****
--- 173,180 ----
retval.resize (0, 0);
else if (idx_j.is_colon_equiv (nc, 1))
retval.resize (0, nc);
+ else if (idx_i.is_colon_equiv (nr, 1))
+ retval.resize (0, m);
else
(*current_liboctave_error_handler) ("invalid row index = 0");
}
***************
*** 182,187 ****
--- 184,191 ----
retval.resize (0, 0);
else if (idx_i.is_colon_equiv (nr, 1))
retval.resize (nr, 0);
+ else if (idx_j.is_colon_equiv (nc, 1))
+ retval.resize (n, 0);
else
(*current_liboctave_error_handler) ("invalid column index = 0");
}