  function F = MyExpCVL(A,tol)
% A is an nxn normalized intensity matrix with n<=1000
% tol satisfies 1/10 <= tol <= 1/10^12
% F approximates F0 = exp(A) with |F(i,j)-F0(i,j)|<=tol
[n,n] = size(A);
% Choosing m = 2^k. Make use of what TestMyExp tells us
if tol <10^(-10)
    fprintf('\nThe value of tol is too small. Reset to 10^(10)\n\n')
    tol = 10^(-10);
end
i = floor(-log10(tol));
tol2k = [1 1 2 4 5 7 9 10 12 14 20 20];
k = tol2k(i);
m = 2^k;
% Compute F = R(A/m)...
I = eye(n,n);
A0 = A/m;
F = (I -A0/2)\(I + A0/2);
% Repeated squaring to compute F^m...
for j=1:k
    F = F*F;
end

% -2 for m chosen constant or with a loop
% Up to -2 for failing all test cases
% 1 pt for randIntensity
% -1 for failing a test case with tol >= 1e-9
% -1 for m obviously unnecessarily large (error a couple orders of magnitude larger than required tol) 


