Rank: 860 based on 163 downloads (last 30 days) and 7 files submitted
photo

Peter Li

E-mail
Company/University
The Salk Institute

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Peter View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
31 Dec 2013 nthperm Directly compute Nth lexicographic permutation Author: Peter Li permutation, mex, c, factorial, radix 15 0
23 Dec 2013 Fast batch generation of permutations Get next block of lexicographic permutations of input vector Author: Peter Li permutation, combinatorics, mex, c, stl 18 1
  • 5.0
5.0 | 1 rating
15 Nov 2013 nth_element MEX wrap of C++ nth_element. Plus fast_median, a faster median function. In-place and parallel. Author: Peter Li nth_element, c, mex, median, selection, selection algorithm 34 24
  • 4.75
4.8 | 4 ratings
13 Sep 2012 waitfordata Block Matlab while specified fig is open, then grab APPDATA when fig is closing. Author: Peter Li gui 17 0
08 Nov 2011 More intuitive subplot Matlab's subplot is useful for throwing figures together but the indexing is very counter-intuitive. Author: Peter Li plot, gui 17 2
Comments and Ratings by Peter View all
Updated File Comments Rating
22 Dec 2013 Fast batch generation of permutations Get next block of lexicographic permutations of input vector Author: Peter Li

If you only need a few specific permutations given their lexicographic order numbers, use my NTHPERM submission.

18 Dec 2013 VChooseKO Choose K elements from a vector without repetitions and with order [MEX] Author: Jan Simon

This sounds useful, but would be nice to be able to generate the permutations in blocks so that if there are too many for memory it can still be done in batches.

I think I will make a version based on C++ STL NEXT_PERMUTATION.

18 Dec 2013 ONEPERM Obtain a single permutation of the numbers 1:N Author: Darren Rowland

Ah, based on recursive permutation as here: http://www.mathworks.com/matlabcentral/fileexchange/13060-perms1

So not in the same order as Matlab PERMS or C++ STL NEXT_PERMUTATION. I guess this means I can't use this as starting points for a multithreaded version based on STL.

18 Dec 2013 nextperm Outputs the next permutation of the ordered tuple x. Author: Steven Gregory

This looks like the same algorithm used in the C++ STL next_permutation. Probably going to be faster to call C++; I might write that.

17 Nov 2013 nth_element MEX wrap of C++ nth_element. Plus fast_median, a faster median function. In-place and parallel. Author: Peter Li

Heh, the plot thickens; in R2012a median doesn't take integer inputs at all! Glad they decided to walk that one back, although the return 0 for empty input is a bad bug; I'll report it.

Comments and Ratings on Peter's Files View all
Updated File Comment by Comments Rating
21 Feb 2014 Fast batch generation of permutations Get next block of lexicographic permutations of input vector Author: Peter Li Husain, Farzad

22 Dec 2013 Fast batch generation of permutations Get next block of lexicographic permutations of input vector Author: Peter Li Li, Peter

If you only need a few specific permutations given their lexicographic order numbers, use my NTHPERM submission.

17 Nov 2013 nth_element MEX wrap of C++ nth_element. Plus fast_median, a faster median function. In-place and parallel. Author: Peter Li Li, Peter

Heh, the plot thickens; in R2012a median doesn't take integer inputs at all! Glad they decided to walk that one back, although the return 0 for empty input is a bad bug; I'll report it.

16 Nov 2013 nth_element MEX wrap of C++ nth_element. Plus fast_median, a faster median function. In-place and parallel. Author: Peter Li Li, Peter

Really, it returns zero now? That sounds like a worse bug than before; in many cases zero can be a real median value. Empty output or throw exception seems like the only correct behavior for empty integer input.

I think rather than add a second input flag, I'll punt and suggest you just wrap fast_median with a check for empty input if you really need it to behave like default median. I don't think this should slow things down significantly, but let me know if it's not workable.

16 Nov 2013 nth_element MEX wrap of C++ nth_element. Plus fast_median, a faster median function. In-place and parallel. Author: Peter Li Komarov, Oleg

Although, I agree that it makes sense to return empty for empty input for practical purposes it would be useful to e.g. have a flag as second input in order to change the default return value in case of empty input. his is because I have a complex routine that relies on the default behaviour of median.

Also, on R2013a median(zeros(0,'int32')) returns zero (they corrected the bug).

Contact us