[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Add min/max tests. (4/4)
From: |
Paul Kienzle |
Subject: |
Re: [PATCH] Add min/max tests. (4/4) |
Date: |
Fri, 8 Sep 2000 13:51:07 +0100 |
User-agent: |
Mutt/1.2.5i |
On Thu, Sep 07, 2000 at 08:53:42PM -0500, John W. Eaton wrote:
> On 8-Sep-2000, Paul Kienzle <address@hidden> wrote:
>
> | To make it completely proper is a bit more work. You must protect the
> | do_fortran_indexing state.
>
> For the (relatively common) case where a single matrix index is the
> result of a call to find(), it seems like it would make more sense to
> return a special `indexing object' that could be used on a matrix of
> the same shape as the one passed to find() without having to worry
> about do_fortran_indexing. Would that make sense, or do you think it
> would also be too restrictive?
>
> jwe
>
>
Actually, in this case I should have coded it without the find() as:
z = x;
idx = abs(x) > abs(y);
z(idx) = y(idx);
which gives the same result 2-3 times faster (at least with 2.1.31).
Since this will work in almost all cases, it doesn't make sense to
create a data type just for the return from find. Compatibility with
matlab is more compelling, but you get that just by setting
do_fortran_indexing = 1.
Note that you still need do_fortran_indexing == 1 to handle the nargin==1
case:
[z, zi] = min(abs(x));
[nr, nc] = size(x);
if (nr == 1 || nc == 1)
z(zi) = x(zi);
else
dfi = do_fortran_indexing;
unwind_protect
do_fortran_indexing = 1;
z = x(zi + [0:nc-1]*nr);
unwind_protect_cleanup
do_fortran_indexing = dfi;
end_unwind_protect
endif
A counter question: why would you ever want do_fortran_index == 0?
- Paul
- Re: [PATCH] Add min/max tests. (4/4), (continued)
- Re: [PATCH] Add min/max tests. (4/4), Edward Jason Riedy, 2000/09/04
- Re: [PATCH] Add min/max tests. (4/4), John W. Eaton, 2000/09/05
- Re: [PATCH] Add min/max tests. (4/4), John W. Eaton, 2000/09/06
- Re: [PATCH] Add min/max tests. (4/4), Edward Jason Riedy, 2000/09/13
- Re: [PATCH] Add min/max tests. (4/4), John W. Eaton, 2000/09/13
- Re: [PATCH] Add min/max tests. (4/4), Edward Jason Riedy, 2000/09/13
- Python (was: Re: [PATCH] Add min/max tests. (4/4)), John W. Eaton, 2000/09/13
- Re: Python (was: Re: [PATCH] Add min/max tests. (4/4)), Edward Jason Riedy, 2000/09/14
Re: [PATCH] Add min/max tests. (4/4), Paul Kienzle, 2000/09/07