function [V,d] = prodEIGS(A,k,opts)
% A is a length-m cell array of n-by-n sparse-format matrices.
% k is a positive integer.
% opts is a valid options structure for the function eigs.
% V is an n-by-k matrix and d is a column k-vector with the property
% that we approximately have
% A{1}A{2}...A{d}*V(:j) = d(j)V(:,j) j=1:k
% where d(1),...,d(k) are the k largest eigenvalues in absolute value
% of the matrix A{1}A{2}...A{d}.
% Uses eigs with options specified by opts

[n,n] = size(A{1});
[V,D] = eigs(@(x)MyProd(x,A),n,k,'LM',opts);
d = diag(D);

function y = MyProd(x,A)
% A is a length m cell array of n-by-n matrices
% and y = A{1}*A{2}...*A{m}x
m = length(A);
y = x;
for k=m:-1:1
y = A{k}*y;
end