function [X,res,flag] = residuals(this,A,X,t,o)
    
    pos = this.nametype == 3;
    ne = sum(pos);

    e0 = zeros(ne,1);
    
    [e1,~,res,flag] = lsqnonlin(@do_objfunc,e0,[],[],o);
    X(pos,t) = e1;
    
    function obj = do_objfunc(p)
        X(pos,t) = p;
        obj = this.eqtnall(A,X,t);
    end
    
end