blob: d6efbe910ad6a544d709139b58787f34bfe79fd5 (
plain)
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
|
function S_permuted = xxpp_to_xpxp(S)
% Permutes the entries of the input from xxpp ordering to xpxp ordering.
%
% Args:
% S (array): input even dimensional square matrix or array
%
% Returns:
% S_permuted (array): permuted matrix or array
shape = size(S);
n = shape(1);
if mod(n, 2) ~= 0
error('The input array is not even-dimensional');
end
n = n / 2;
ind = reshape(1:2*n, 2, [])';
ind = ind(:);
if length(shape) == 2
if shape(1) ~= shape(2)
error('The input matrix is not square');
end
S_permuted = S(ind, ind);
else
S_permuted = S(ind);
end
end
|