%                       coefsSproc.m
% Coefficients of selected processed Method-Adjoint compositions
% S_h= P_h^(-1) K_h P_h 
%  S_h = 
%    chi_{gp_{1}h}^*·chi_{gp_{2}h}··· chi_{ga_{2np-1}h}^*·chi_{ga_{2np}h}
%    chi_{ga_{2s}h}·chi^*_{ga_{2s-1}h}··· chi_{ga_{2}h}·chi^*_{ga_{1}h}
%    chi_{gp_{2np}h}·chi^*_{gp_{2np-1}h}··· chi_{gp_{2}h}·chi^*_{gp_{1}h}
% Collected methods with s-stage kernels with s={1 4,5,6,10}
% S. Blanes, F. Casas and A. Murua, Splitting methods for differential equations,
%   Acta Numerica (2024)     (Section 8, Table 8.2)

function [ga gp np] = coefsSproc(s)
% s = Number of stages 
if  (s==4)  % 4th-order: Blanes-Casas-Ros (BCR99)
    a1=(57+sqrt(18069))/300;
    a=[a1,1/2-a1,1/2-a1,a1];
    b1=6/25; b2=-1/10; 
    b=[b1,b2,1-2*(b1+b2),b2,b1];
    ga(1)=b(1);
    ga(2)=a(1)-ga(1);
    for i=2:4
        ga(2*i-1)=b(i)-ga(2*i-2);
        ga(2*i)=a(i)-ga(2*i-1);
    end
    
    % Coefficients for the processor
    np=4;
    z1=-0.1171835753202670; z2=0.8785444960116207; z3=-0.8972532123604465;
    z4=-(z1+z2+z3);
    y1=-0.5903105192555323; y2=0.00137327945651155115; y3=0.3958521503201655;
    y4=-(y1+y2+y3);
    z=-[z1, z2, z3, z4];
    y=-[y1, y2, y3, y4];
    
      ga(1)=b(1);  gp(1)=0;
      ga(2)=a(1)-ga(1); gp(2)=z(1)-gp(1);
      for i=2:4
        ga(2*i-1)=b(i)-ga(2*i-2);
        ga(2*i)=a(i)-ga(2*i-1);
         gp(2*i-1)=y(i-1)-gp(2*i-2);
         gp(2*i)=z(i)-gp(2*i-1);
      end

elseif (s==6)   % 4th-order: Blanes-Casas-Murua (BCM06)
    ga(1)=0.1341940158122142;
    ga(2)=ga(1);
    ga(3)=ga(1);
    ga(4)=ga(1);
    ga(5)=-ga(1)-0.18;
    ga(6)=1/2-(ga(1)+ga(2)+ga(3)+ga(4)+ga(5));
    ga(7)=ga(6);
    ga(8)=ga(5);
    ga(9)=ga(4);
    ga(10)=ga(3);
    ga(11)=ga(2);
    ga(12)=ga(1);
  % Coefficients for the processor
    np=6;
    gp(1)=0;
    gp(3)=-0.1612056894758833;
    gp(4)=-0.2694936673582758;
    gp(5)=0.2736158718483377;
    gp(6)=0.1832420262145362;
    gp(2)=-(gp(3)+gp(4)+gp(5)+gp(6));
    for ip=1:6
        gp(6+ip)=-gp(ip);
    end

elseif (s==9)  % 6th-order: Blanes-Casas-Murua (BCM06)
    ga(1)=0.1106570871853300;
    ga(2)=ga(1);
    ga(3)=ga(1);
    ga(4)=ga(1);
    ga(5)=ga(1);
    ga(6)=-0.2854111127287940;
    ga(7)=0.2138498496192465;
    ga(8)=-0.3402583791791715;
    ga(9)=1/2-(ga(1)+ga(2)+ga(3)+ga(4)+ga(5)+ga(6)+ga(7)+ga(8));
    for ii=1:9
        ga(9+ii)=ga(10-ii);
    end

  % Coefficients for the processor
     np=12;
     gp(1) =  0.076084901600069 ;
     gp(2) = -0.123246517351247 ;
     gp(3) = -0.024492586981581;
     gp(4) = -0.029963588164372 ;
     gp(5) =  0.190472176568198 ;
     gp(6) =  0.314129164156584;
     gp(7) =  0.264178537063627 ;
     gp(8) = -0.270358079196099 ;
     gp(9) = -0.324376936334263;
     gp(10) =-0.162284700519294 ;
     gp(11) = 0.076073416537601 ;
     gp(12) = 0.305391455435821;
     gp(13) = 0.234669529217505 ;
     gp(14) = 0.204415922942361 ;
     gp(15) =-0.051834728932456;
     gp(16) =-0.410967687272985 ;
     gp(17) = 0.412555725541299 ;
     gp(18) = 0.038655677373676;
     gp(19) =-0.204654079212777 ;
     gp(20) =-0.240780293695790 ;
     gp(21) = 0.069762371965259;
     gp(22) =-0.049056671795592 ;
     gp(23) =-0.294373008945545;
    gp(24)=0;
    for k=1:24
       gg(25-k)=-gp(k) 
    end
    gp=gg;

end

