cosmo randperm hdr

function rp=cosmo_randperm(n,varargin)
% generate random permutation of integers
%
% cosmo_randperm(n[,count][,'seed',seed])
%
% Inputs:
%   n                       Maximum value of output
%   count                   (optional) number of elements to return; count
%                           must not be larger than n.
%                           Default: count=n
%   'seed',seed             (optional) use seed for determistic
%                           pseudo-random number generation. If provided
%                           then subsequent calls to this function with the
%                           same input arguments will always give the same
%                           output. If not provided, then subsequent calls
%                           will almost always give different outputs
%
% Output:
%   rp                      row vector with count elements, with all
%                           numbers in the range 1:n. Numbers are sampled
%                           from 1:n without replacement, in other words rp
%                           does not contain repeats.
%