% Input
% SigmaTau : Matrix (expm(t*A))
% Pinit : function handle (support function of initial set)
% Pw : function handle (support function overapproximating BU)
% l : row-vector (Direction)
% N : integer (number of sets to generate)

% Output:
% x: vector (1xN vector containing the evaluation results in direction l)

% Description:
% Algorithm (1) to evaluate support function from Omega0 to OmegaN-1
% from "Reachability Analysis of Linear Systems using Support Functions"
% Computes the evaluation of the support function in direction l

function [p] = algo1(SigmaTau,Pinit,Pw,l,N)
r=l;
r_old = r;

s = zeros(N,1);
p(1, 1) = Pinit(r(:,1));

for i = 1:1:N-1
    temp = SigmaTau' * r_old;
    r = temp;
    
    s(i+1) = s(i) + Pw(r_old);  
    p(1,i+1) = Pinit(r)+s(i+1);
    
    r_old = r;
end;
