Code covered by the BSD License  

Highlights from
The JSR toolbox

image thumbnail

The JSR toolbox

by

 

10 Oct 2011 (Updated )

Gathers and compares the best methods for the joint spectral radius computation

liftProduct(M, k)
function P = liftProduct(M, k)

% LIFTPRODUCT Generation of the set of all k-products of matrices of a set
%
%    P = liftProduct(M, k) returns a cell array of all products of k matrices
%      taken from the set M. The same matrix can appear several times in the
%      product, and P may contain several identical products

n = length(M);
m = size(M{1}, 1);
P = liftProductRecursive(cell(n^k, 1), M, n, eye(m), k-1, 0);



function P = liftProductRecursive(P, M, n, prod, k, shift)

if (k <= 0),
    for i = 1:n,
        P{shift+i, 1} = prod*M{i};
    end
    return
end

for i = 1:n,
    P = liftProductRecursive(P, M, n, prod*M{i}, k-1, shift+(i-1)*n^k);
end

Contact us