Detect bifurcation points, compute their normal form and insert into branch

(with refinement)

Contents

function [bifpoints,biflow,branch,indices]=br_insert(funcs,branch,detect,varargin)

Input

Examples of prepared functions for detect cell array (in ddebiftool_utilities): TakensBogdanovNormalform, ZeroHopfNormalform, CuspNormalform, HopfHopfNormalform, GeneralizedHopfNormalform.

Output

$Id$

default={'print',0};
[options,pass_on]=dde_set_options(default,varargin,'pass_on');
isbif=@(d)cellfun(@(x)~isempty(x),d);
nextbif=@(d,ind)find(isbif(d(ind+1:end)),1,'first')+ind;
nbifs=sum(isbif(detect));
bifpoints={};
biflow={};
indices=[];
curbif=0;
curind=0;
npoints=length(branch.point);
while curbif<nbifs
    curind=nextbif(detect,curind);
    curbif=curbif+1;
    [bifpoints{curbif},biflow{curbif},branch,indices(curbif)]=detect{curind}(...
        funcs,branch,curind+(0:1),pass_on{:},'print',options.print-1); %#ok<AGROW>
    if options.print>0 && ~isempty(bifpoints{curbif}) && ...
            isstruct(bifpoints{curbif}) && isfield(bifpoints{curbif},'kind');
        fprintf('br_insert: detected %d of %d: %s. Normalform:\n',curbif,nbifs,bifpoints{curbif}.kind);
        disp(bifpoints{curbif}.nmfm);
    end
    nnewpoints=length(branch.point)-npoints;
    detect=[detect(1:curind),cell(1,nnewpoints),detect(curind+1:end)];
    curind=curind+nnewpoints;
    npoints=length(branch.point);
end
end