1function Y = solveSylvPowersDirectSum(A, B, C)
2% X = solveSylvPowersDirectSum() solves the equation
3% sum_{j=1}^N B_j Y A^{j-1} = C, directly
5% B = [B_1 B_2 ... B_N], B_j: n x n
18 Avec(:,i*m+1:(i+1)*m) = Avec(:,(i-1)*m+1:i*m)*Avec(:,m+1:2*m);
21%Z: matrix coeff of vec(Y)
24 Z = Z + kron(Avec(:,(j-1)*m+1:j*m), B(:,(j-1)*n+1:j*n));
27Y = Z\(reshape(C,m*n,1));