function R = ErrCBPS(A,B,C,D,E,F,X)
    [m,m1,n] = size(A);
    for k = 1:n
        if (k == 1)
            R(:,k) = A(:,:,k)*X(:,n-1)+B(:,:,k)*X(:,n)+C(:,:,k)*X(:,k)+D(:,:,k)*X(:,k+1)+E(:,:,k)*X(:,k+2)-F(:,k);
        elseif (k == 2)
            R(:,k) = A(:,:,k)*X(:,n)+B(:,:,k)*X(:,k-1)+C(:,:,k)*X(:,k)+D(:,:,k)*X(:,k+1)+E(:,:,k)*X(:,k+2)-F(:,k);
        elseif (k == n-1)
            R(:,k) = A(:,:,k)*X(:,k-2)+B(:,:,k)*X(:,k-1)+C(:,:,k)*X(:,k)+D(:,:,k)*X(:,k+1)+E(:,:,k)*X(:,1)-F(:,k);            
        elseif (k == n)
            R(:,k) = A(:,:,k)*X(:,k-2)+B(:,:,k)*X(:,k-1)+C(:,:,k)*X(:,k)+D(:,:,k)*X(:,1)+E(:,:,k)*X(:,2)-F(:,k);       
        else
            R(:,k) = A(:,:,k)*X(:,k-2)+B(:,:,k)*X(:,k-1)+C(:,:,k)*X(:,k)+D(:,:,k)*X(:,k+1)+E(:,:,k)*X(:,k+2)-F(:,k);
        end
    end
    %R = abs(R);
    err_max = max(max(abs(R)))
    err_ave = sum(sum(abs(R)))/(n*m)
return;
    