/usr/share/freemat/toolbox/random/randperm.m is in freemat-data 4.0-5build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | % RANDPERM RANDPERM Random permutation
%
% Usage
%
%
% y = randperm(n)
%
% y is a random permutation of integers from 1 to n.
% randperm calls rand and changes its state.
% Copyright (c) 2008 Samit Basu
% Licensed under the GPL
function result = randperm(n)
% % Slow version
% m = floor(n);
% result = 1:m;
% for ii = 1:m
% jj = round(rand(1,1)*(m-1))+1;
% temp = result(ii);
% result(ii) = result(jj);
% result(jj) = temp;
% end
% This is much faster
[A, result] = sort(rand(1,n));
end
|