function data = computeaddfullafsCAA(object, data, Footnote, Polysettings, ipia)

k = data.k;
n = data.n;
s = data.s;
noiseC = data.noiseC;
V = data.V;
U = data.U;
S = data.S;

data.full.isC = 0;
data.full.isA = 0;

data.full.AFSC = [];
data.full.AFSA = [];

MaxLang = 10000;
MaxFunC = 20000;
epsFun = 1.e-10;
epsKante = getsetvar(Polysettings(3), 1.E-8, 1.E-1, 0, 1);
epsRand = getsetvar(Polysettings(2), 1.E-8, 1.E-1, 0, 1);
noiseC = -getsetvar(Polysettings(1), 1.E-12, data.maxnoise, 0, 0);
noiseA = noiseC;

U = data.U;
S = data.S;
V = data.V;

[k,n] = size(data.D);
s = 3;

actpwd = pwd;
cd(data.calca);

fprintf(' C routine (AFS for factor S) in progress ... (press CTRL + C to cancel) ... ');
set(object, 'Enable','off');

set(gcf,'Pointer','Watch');
pause(0.5);

if get(ipia(1),'Value') == 1
    [AFS, d.uy1,d.uy2,d.uy3,tim,parts,dimP,d.uy4,d.uy5,valid,lines] = computeAFS(MaxLang,MaxFunC,epsFun,epsKante,epsRand,noiseC,noiseA,s,U,S,V,data.InitT,4,pwd,ipia(2));
else
    [AFS, d.uy1,d.uy2,d.uy3,tim,parts,dimP,d.uy4,d.uy5,valid,lines] = computeAFS(MaxLang,MaxFunC,epsFun,epsKante,epsRand,noiseC,noiseA,s,U,S,V,data.InitT,3,pwd,ipia(2));
end

data.full.AFSA = AFS;
data.full.timA = tim;
data.full.partsA = parts;
data.full.dimA = dimP;
data.full.validA = valid;
data.full.linesA = lines;

colfn = 'k';
if parts > 0
    fprintf('ready, time: %2.2f s.\n',tim);
    strfn = [' AFS computation time for S: ',num2str(tim,'%2.2f'),' s'];
    data.full.isA = 1;
else
    fprintf('computation canceled or failed.\n');
    strfn = ' AFS computation for S canceled or failed';
    colfn = 'r';
    data.full.isA = 0;
end

s = k;
k = n;
n = s;
s = 3;

InitT = pinv(data.InitT)'*S(1:3,1:3)';
for i=1:3
    InitT(i,:) = InitT(i,:)/InitT(i,1);
end

U = data.V;
S = data.S';
V = data.U;

fprintf(' C routine (AFS for factor C) in progress ... (press CTRL + C to cancel) ... ');

if get(ipia(1),'Value') == 1
    [AFS, d.uy1,d.uy2,d.uy3,tim,parts,dimP,d.uy4,d.uy5,valid,lines] = computeAFS(MaxLang,MaxFunC,epsFun,epsKante,epsRand,noiseC,noiseA,s,U,S,V,InitT,4,pwd,ipia(2));
else
    [AFS, d.uy1,d.uy2,d.uy3,tim,parts,dimP,d.uy4,d.uy5,valid,lines] = computeAFS(MaxLang,MaxFunC,epsFun,epsKante,epsRand,noiseC,noiseA,s,U,S,V,InitT,3,pwd,ipia(2));
end

for i=1:lines
    if valid(i)
        AFS{i}(:,1) = AFS{i}(:,1)*S(1,1)/S(2,2);
        AFS{i}(:,2) = AFS{i}(:,2)*S(1,1)/S(3,3);
    end
end

data.full.AFSC = AFS;
data.full.timC = tim;
data.full.partsC = parts;
data.full.dimC = dimP;
data.full.validC = valid;
data.full.linesC = lines;

if parts > 0
    fprintf('ready, time: %2.2f s.\n',tim);
    strfn = [strfn,',  AFS computation time for C: ',num2str(tim,'%2.2f'),' s'];
    data.full.isC = 1;
else
    fprintf('computation canceled or failed.\n');
    strfn = [strfn,',  AFS computation for C canceled or failed'];
    colfn = 'r';
    data.full.isC = 0;
end
set(Footnote,'String',strfn,'ForegroundColor',colfn);

set(gcf,'Pointer','arrow');
set(object,'Enable','on');

cd(actpwd);

if isempty(data.xlc)
    if data.full.isC
        data.xlc = [inf -inf];
        data.ylc = [inf -inf];
        for i=1:data.full.linesC
            if data.full.validC(i)
                data.xlc = [min(data.xlc(1), min(data.full.AFSC{i}(:,1))), max(data.xlc(2), max(data.full.AFSC{i}(:,1)))];
                data.ylc = [min(data.ylc(1), min(data.full.AFSC{i}(:,2))), max(data.ylc(2), max(data.full.AFSC{i}(:,2)))];
            end
        end
        data.xlc = 1.5*data.xlc;
        data.ylc = 1.5*data.ylc;
    else
        data.xlc = [0 2];
        data.ylc = [-1 1];
    end
end

if isempty(data.xla)
    if data.full.isA
        data.xla = [inf -inf];
        data.yla = [inf -inf];
        for i=1:data.full.linesA
            if data.full.validA(i)
                data.xla = [min(data.xla(1), min(data.full.AFSA{i}(:,1))), max(data.xla(2), max(data.full.AFSA{i}(:,1)))];
                data.yla = [min(data.yla(1), min(data.full.AFSA{i}(:,2))), max(data.yla(2), max(data.full.AFSA{i}(:,2)))];
            end
        end
        data.xla = 1.5*data.xla;
        data.yla = 1.5*data.yla;
    else
        data.xla = [0 2];
        data.yla = [-1 1];
    end
end
