From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Getting indexes of rows of matrix with more than n repetitions
Date: Sat, 9 Jan 2010 11:47:04 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 20
Message-ID: <hi9qbn$qmn$>
References: <hhudae$4p$> <hhuths$led$> <hi023t$mtq$> <hi1f7i$plv$> <hi1g5n$f7i$> <hi1ua1$d7e$> <hi2300$6dk$> <hi25nk$5lo$> <hi2maq$8ba$> <hi2u1m$pg5$>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1263037624 27351 (9 Jan 2010 11:47:04 GMT)
NNTP-Posting-Date: Sat, 9 Jan 2010 11:47:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: comp.soft-sys.matlab:597656

"Jan Simon" <> wrote in message <hi2u1m$pg5$>...
> Dear Bruno!
> > Jan, how much do you estimate an inplace sorting (e.g., on large double array) would save time?
> It is clear, that the creation of the sort index is the demanding part of SORT, while the copy of the input in sorted order is secondary - usually. Unfortuantely one of the 2 DIMM ports of my computer is damaged and I have to live with 512MB RAM. But saving temporarily used memory is always useful, even on a 16 GB machine. Nevertheless, timing matters for 8MB array already:
> For the estimation of the speed gain:
>   x = rand(1e6, 1);
>   tic; y = sort(x); toc  ==> 0.26 sec
>   tic; [y, s] = sort(x); toc  ==> 0.40 sec
>   tic; y = x(s); toc ==> 0.14 sec
> So I assume I could save 35% computing time.

Bad news, I implement an in-place 1D quicksort (the unstable version) and it get beaten by Matlab SORT with two outputs calling. My Matlab is 2010A prerelease; I compile the mex with MSVC 6. My guess is inplace sorting requires accessing in cascade the double data, and it slows the thing down.

So I won't go any further. Better spend the effort on something else.