/usr/share/psychtoolbox-3/PsychOneliners/Magnify2DMatrix.m is in psychtoolbox-3-common 3.0.9+svn2579.dfsg1-1.
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | function destination = Magnify2DMatrix(source, scalingFactor)
% destination = Magnify2DMatrix(sourceMatrix, scalingFactor)
%
% Magnifies a 2-D or 3-D 'sourceMatrix' by a factor specified by
% 'scalingFactor'. size of 3rd dimension will not be scaled.
%
% 10/15/06 rhh Wrote it using lots of loops.
% 11/12/06 rhh Revised it. Denis Pelli suggested revising the code to take
% advantage of Matlab's matrix processing abilities and David Brainard
% showed explicitly how this could be done.
% 05/09/08 DN generated copy instruction indices with a different method,
% speeding up this function. Added support for 3D matrices
heightOfSource = size(source,1);
widthOfSource = size(source,2);
% Generate row copying instructions index.
inds = 1:heightOfSource;
rowCopyingInstructionsIndex = inds(ones(scalingFactor,1),:);
rowCopyingInstructionsIndex = rowCopyingInstructionsIndex(:);
% Generate column copying instructions index.
inds = 1:widthOfSource;
columnCopyingInstructionsIndex = inds(ones(scalingFactor,1),:);
columnCopyingInstructionsIndex = columnCopyingInstructionsIndex(:)';
% The following code uses Matlab's matrix indexing quirks to magnify the
% matrix. It is easier to understand how it works by looking at a specific
% example:
%
% >> n = [1 2; 3 4] % Matlab, please give me a matrix with four elements.
%
% n =
%
% 1 2
% 3 4
%
% >> % Matlab, please generate a new matrix by using the provided copying
% >> % instructions index. My copying instructions index says that you
% >> % should print the first column twice, then print the second column
% >> % twice. Thanks.
% >> m = n(:, [1 1 2 2])
%
% m =
%
% 1 1 2 2
% 3 3 4 4
%
% >> % Matlab, please generate a new matrix by using the provided copying
% >> % instructions index. My copying instructions index says that you
% >> % should print the first row twice, then print the second row
% >> % twice. Thanks.
% >> m = n([1 1 2 2], :)
%
% m =
%
% 1 2
% 1 2
% 3 4
% 3 4
%
destination = source(rowCopyingInstructionsIndex, columnCopyingInstructionsIndex,:);
|