-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkroneckerSliceShift.m
More file actions
34 lines (28 loc) · 915 Bytes
/
Copy pathkroneckerSliceShift.m
File metadata and controls
34 lines (28 loc) · 915 Bytes
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
function[AShifted] = kroneckerSliceShift(A)
%------------------------------------------------------------------------
%
% kroneckerSliceShift.m:
% Takes a square matrix of size m, and returns a matrix of size m x m.^2
% such that each row consists of elements of the corresponding row in the
% original matrix separated by m-1 zeros, and each row is shifted to the
% right by its index-1 zeros. Uses Kronecker product to do this.
%
% Inputs:
% A: The matrix to shift
%
% Outputs:
% AShifted: The shifted matrix
%
%------------------------------------------------------------------------
% A is assumed to be square (and transposed in the case of BSS)
% Get length of side and ensure square-ness
length = size(A, 1);
assert(length == size(A, 2));
% Get I
I = eye(length);
% Initialize AShifted
AShifted = zeros(length, length.^2);
for i=1:length
AShifted(i, :) = kron(A(i, :), I(i, :));
end
end