Path: news.mathworks.com!not-for-mail
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$1@fred.mathworks.com>
References: <hhudae$4p$1@fred.mathworks.com> <hhuths$led$1@fred.mathworks.com> <hi023t$mtq$1@fred.mathworks.com> <hi1f7i$plv$1@fred.mathworks.com> <hi1g5n$f7i$1@fred.mathworks.com> <hi1ua1$d7e$1@fred.mathworks.com> <hi2300$6dk$1@fred.mathworks.com> <hi25nk$5lo$1@fred.mathworks.com> <hi2maq$8ba$1@fred.mathworks.com> <hi2u1m$pg5$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1263037624 27351 172.30.248.35 (9 Jan 2010 11:47:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 9 Jan 2010 11:47:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:597656

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <hi2u1m$pg5$1@fred.mathworks.com>...
> 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.

Bruno