function [A,b] = mkp1d(P,T,k,f,ID,uD,IN,tau)

n = size(P,2);
m = size(T,2);
mN = size(IN,2);

Atilda = sparse(n+1,n+1);
btilda = zeros(n+1,1);

for p=1:m
    Tp = T(:,p);
    Xp = P(:,Tp);
    u = Xp(:,2)-Xp(:,1); v = Xp(:,3)-Xp(:,1);
    Rp = [u,v]; invRpt = inv(Rp)';
    obsahTp = 0.5*abs(det(Rp));
    
    Bp = invRpt*[-1 1 0;-1 0 1];
    Ap = k(p)*obsahTp * Bp'*Bp;
    
    bp = (f(p)*obsahTp/3)*[1;1;1];
    
    Atilda(Tp,Tp) = Atilda(Tp,Tp) + Ap;
    btilda(Tp) = btilda(Tp) + bp;
end

for p=1:mN
    Sp = IN(:,p);
    Xp = P(:,Sp);
    delkaSp = norm(Xp(:,2)-Xp(:,1));
    
    cp = (tau(p)*delkaSp/2)*[1;1];
    
    btilda(Sp) = btilda(Sp) + cp;
end

idx = setdiff(1:n,ID);
A = Atilda(idx,idx);
b = btilda(idx) - Atilda(idx,ID)*uD;