% The disorder function in real space
% Input: 
%   D - vector of k-valued disorder
%   u - the value of point in real space to be evaluated
%   eta - dimensionless string velocity
%   lambda - string length
%   order - when is set to 0 then D(u) is returned, when is set to 2 D''(u)
%   is returned

function Du = realDis(D,u,eta,lambda,order)
    N = length(D);
    U = length(u);
    B = 1;
    for i = 1:U
        sum = 0;
        for n = 1:N
            k = B*2*pi*(n-1)/N;
            etaweight = 1; %real(realpow(eta,-(k*lambda)^2/(2*pi)));
            if order == 0
                sum = sum + etaweight*cos(k*u(i))*D(n);
            elseif order == 2
                sum = sum + etaweight*cos(k*u(i))*k^2*D(n);
            end
        end
        Du(i) = 2*lambda*sum/N;
    end