function type = tjsr_setproblemtype(type, v0properties); 
% type = tjsr_setproblemtype(type, v0properties); 
% This function belongs to tjsr!
% sets the value of type.info.algorithm
% Input:
%   type
%   v0properties        return struct from identifymatrix() of the set of vertices from the root
%
% Written by tommsch, 2018

    if(type.info.matrixtype.nonneg); problemtype='nonneg'; %if the matrices are non-negative, by Perron-Frobenius, the leading eigenvalue is real and positive.
    elseif(~type.info.matrixtype.real); problemtype='complex';
    elseif(v0properties.real); problemtype='real';
    else; problemtype='complex';
    end;
    
    if(isempty(type.info.algorithm) && strcmp(problemtype,'nonneg') || ~isempty(type.info.algorithm) && type.info.algorithm==TJSR_CONEFUNCT); 
        type.info.infotext=vprintf('Use cone-norm.\n','imp',[1,type.opt.verbose],'str',type.info.infotext);
        type.info.algorithm=TJSR_CONEFUNCT;
    elseif(isempty(type.info.algorithm) && strcmp(problemtype,'real') || ~isempty(type.info.algorithm) && type.info.algorithm==TJSR_MINKFUNCT); 
        type.info.infotext=vprintf('Use Minkowski-norm.\n','imp',[1,type.opt.verbose],'str',type.info.infotext);
        type.info.algorithm=TJSR_MINKFUNCT;
    elseif(isempty(type.info.algorithm) && strcmp(problemtype,'complex') || ~isempty(type.info.algorithm) && type.info.algorithm==TJSR_COMPLEXFUNCT); 
        type.info.infotext=vprintf('Use complex-polytope norm.\n','imp',[1,type.opt.verbose],'str',type.info.infotext);
        type.info.algorithm=TJSR_COMPLEXFUNCT;    
    else
        error('Unkown error. ''type.info.problemtype.matrix'' or ''algorithm'' is invalied');
    end;
    
end