function y = lorentzian(a,x)

% Returns a normalized lorentzian 
%   y(x) = (a/pi) / (a^2+x^2)
% Input:
%   a    : vector of lorentzian widths
%   x    : row vector of x values at which y(x) is required
% Output:
%   y(na,nx) : matrix of values of the lorentzians at points x
% Usage:
%   f = lorentzian((1:3),(-10:0.1:+10))
% J.M.Soler. Sept.2012

na = numel(a);
nx = numel(x);
for ia = 1:na
    for ix = 1:nx
        y(ia,ix) = (a(ia)/pi)/(a(ia)^2+x(ix)^2);  % lorentzian values
    end
end

% A compact alternative (requires a and x to be column and row vectors, respectively)
% y = (a/pi)./(a.^2+x.^2);

end
