VChooseKO 1.0 |
Date Added: April 06, 2013 | Visits: 442 |
|
||||||||
VChooseKO(V, K) creates a matrix, which rows are all permutations of choosing K elements of the vector V with order and without repetitions.INPUT: V: Array of class DOUBLE, SINGLE, (U)INT8/16/32/64, LOGICAL, CHAR. K: Number of elements to choose.OUTPUT: Y: [N!/(N-K)!, K] matrix with N is the number of elements of V. Y has the same class as the input V. The rows are sorted in lexicographical order: smaller indices at first.EXAMPLES: Choose 2 elements from [1, 2, 3]: VChooseKO(1:3, 2) % ==> [1,2; 1,3; 2,1; 2,3; 3,1; 3,2] For speed cast the input to integer types or SINGLE whenever possible: Y = VChooseKO(uint8(1:100), 3); % 5 times faster than: Y = VChooseKO(1:100, 3); To get the permutations of cell arrays, permute the index: C = {'a', 'b', 'c', 'd'}; C2 = C(VChooseKO(uint8(1:4), 2)) ==> C2 = {'a','b'; 'a','c'; 'a','d'; 'b','a'; 'b','c'; 'b','d'; ... 'c','a'; 'c','b'; 'c','d'; 'd','a'; 'd','b'; 'd','c'} Equivalent to PERMS: isequal(sortrows(perms(1:5)), VChooseKO(1:5, 5)) % TRUE For an output with sorted values (not indices!), sort the input: X = [3, 1, 2]; VChooseKO(sort(X), 3) ==> [1,2,3; 1,3,2; 2,1,3; 2,3,1; 3,1,2; 3,2,1]The output of VCHOOSEKO(V, K) is equivalent to COMBINATOR(NUMEL(V), K, 'p'), but is remarkably faster (see screenshot). The lexicographical output of VCHOOSEKO can be a benefit also, because a time-consuming SORTROWS can be omitted.Tested: Matlab 6.5, 7.7, 7.8, WinXP, 32 bit, Compilers: BCC5.5, LCC2.4/3.8, Open Watcom 1.8The unit-test function TestVChooseKO is included to test the validitiy and compare the speed with PICK, COMBINATOR and Matlab's PERMS.Precompiled mex: http://www.n-simon.de/mexSee also: VChooseK (no repetitions, no order): FEX #26190 VChooseKRO (repetitions, order): FEX #26242 VChooseKR (repetitions, no order): FEX #26277I'd appreciate suggestions for improvements and bug reports sent through email - thanks.
|
License: Shareware | Size: 20.48 KB |
Development Tools
-
fRMField 1.0
fRMField: Remove field(s) from a struct - fast C-MEXThis function is about 5 to 10 times faster than RMFIELD of Matlab 2009a.T = fRMField(S, Name)INPUT: S: Struct or struct array. Name: String or cell string. Removing a name, which is not a field... |
10 KB | |
Development Tools
-
GetFullPath 1.0
GetFullPath - Get absolute path of a file or folder nameThis function converts a partial or relative name to an absolute full path name. The fast Mex works on Windows only (sorry), but the M-file runs on Windows, MacOS and Unix.FullName =... |
10 KB | |
Games
-
Soliter 1.0
This file named soliter.m is game for one person.Rules and info about the game are in the m-file. This game was tested for Matlab v.5.0 on PC-WIN95 platform. |
20.48 KB | |
Development Tools
-
BlockMean 1.0
BLOCKMEAN - Fast mean of rectangular submatricesThe mean of V*W elements along the 1st and 2nd dimension is calculated. This is no running mean filter: The sizes of the 1st and 2nd dimension are reduced by the factors V and W.I use this as cheap... |
10 KB | |
Development Tools
-
MNEMS 1.0
MNEMS is a MEX MATLAB wrapper for a nonlinear solver called NNES. It is written in C and can be used both in Linux and Windows systems.System requirementsA Linux or Windows system with MATLAB. It was tested with MATLAB ver. 6.0, but it should work... |
593.92 KB | |
Development Tools
-
DAQmx examples 1.0
Examples of using matlab to talk to a National Instruments (NI)DAQ card _without_ the 'data acquisition toolbox'I have mainly used code and examples from Jens Roesner here:http://www.jr-worldwi.de/work/matlab/index.htmlHowever, I had to make a few... |
40.96 KB | |
Development Tools
-
Shuffle (Sripts) 1.0
Shuffle - Random permutation of array elementsThis function is equivalent to X(RANDPERM(LENGTH(X)), but 50% to 85% faster. It uses D.E. Knuth's shuffle algorithm (also called Fisher-Yates) and the cute KISS random number generator (G. Marsaglia).... |
20.48 KB | |
Development Tools
-
CmdWinTool 1.0
Programmatic control of the the command windowOn a netbook with a tiny monitor, the toolbar and the statusbar of Matlab'scommand window occupy valuable space. The function CmdWinTool usesundocumented Java methods to hide these UI elements.But the... |
10 KB | |
Development Tools
-
UNINIT - Create an uninitialized variable (like ZEROS but faster) 1.0
UNINIT is very similar to the ZEROS function, except that UNINIT returns an uninitialized array instead of a zero-filled array. Thus, UNINIT is faster than the ZEROS function for large size arrays. Since the return variable is uninitialized, the... |
10 KB | |
Graphs and Charts
-
aviplayer 1.0
function aviplayer(varargin)% AVIPLAYER(VARARGIN)%% This function may be called with 1 or no input arguments; either way, it launches a full-featured AVI player,% complete with "play," "pause," "forward," "reverse," "loop," "inter-frame pause,"... |
10 KB |
Scripts
-
Freelancer Script 5.05
Main Features: 100% Secured. Email Support (3 Years). FREE Updates (3 Years). Post projects. Featured projects. Private projects. Sealed projects. Edit/delete projects. Select freelancers.... |
5.49 MB | |
Scripts
-
B2B Script 4.20
Main Features: 100% Secured. Email Support (3 Years). FREE Updates (3 Years). Sign-up Account (Registration of account). Lead generation tools (for the sellers). Email verification to... |
5.49 MB | |
Scripts
-
B2C Script 5.06
Main Features: 100% Secured. Email Support (3 Years). FREE Updates (3 Years). The script comes with totally editable site colors, icons and graphics Multilevel categories allows extensive browsing Admin can change Category ordering or... |
5.49 MB | |
Scripts
-
Social Networking Script 2.86
Main Features: 100% Secured. Email Support (3 Years). FREE Updates (3 Years). Registration with name, email, password, date of birth etc. User can add multiple school, college, university with start... |
5.49 MB | |
Scripts
-
Business Networking Script 8.04
Main Features: 100% Secured. Email Support (3 Years). FREE Updates (3 Years). Ajax based interface. Profile creation. Different types of profile. Profile for jobseekers, employers and employed... |
5.49 MB | |
Development Tools
-
Aml2CHM 3.50
Those who use the popular Aml Pages text editor might be looking out for a way of generating help files from their text and notes. Aml2CHM is a plug-in that was developed to offer people a quick and efficient way of converting Aml Pages documents... |
549.99 KB | |
Development Tools
-
VMP Viewer 1.0
This is a very rudimentary tool to visualize the VMP files generated by BrainVoyager. Useful to share files with people who do not have BV. |
10 KB | |
Development Tools
-
Sending reports and timestamped file by emailing 1.0
main executing reference usage:[1] usage_send_mail.mIllustrates email sending with multiple separate files or single timestamped tar file. Attachment failure is properly handled, with continuation of report emailing without the attachment.[2]... |
768 KB | |
Development Tools
-
IrisMVC 2.0 rc1
IrisMVC is an OOP PHP framework that developers can use as a strong and secure foundation to build on various web applications following the Model-View-Controller (MVC) pattern. It provides the basic functionality developers need, without... |
51.2 KB | |
Development Tools
-
7-Zip for Script 4.42
7-Zip is a file archiver with a high compression ratio.Features:- High compression ratio in new 7z format with LZMA compression- Supported formats:- Packing / unpacking: 7z, ZIP, GZIP, BZIP2 and TAR- Unpacking only: RAR, CAB, ISO, ARJ, LZH, CHM,... |
624.64 KB |