From: Pink Panther on
"Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hv8uu2$5dk$1(a)fred.mathworks.com>...
> "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hv8qik$5fk$1(a)fred.mathworks.com>...
> > "Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hv8pvu$qc0$1(a)fred.mathworks.com>...
> > > In any case, the median operation probably takes the lion's share of cpu time.
> >
> > It's surely not optimally implemented in Matlab with sorting. The median could be retrieve in linear time.
> >
> > Bruno
>
> You are right about that Bruno (as usual.) The recursive "median of the medians" algorithm, (which I've only just now become aware of,) can make it order N, though it is a rather complicated affair. I wonder if Mathworks has actually implemented such an algorithm in their 'median' routine.
>
> I still think it would take considerably more cpu time than the intermediate step of simply constructing a temporary vector of non-zeros in this problem, at least for long vectors.
>
> Roger Stafford


thanks guys, very instructive on points not even thought about initially, as always.