C4coeff.m 1.38 KB
Newer Older
Valentin Platzgummer's avatar
Valentin Platzgummer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
function C4x = C4coeff(n)
%C4COEFF  Evaluate coefficients for C_4
%
%   C4x = C4COEFF(n) evaluates the coefficients of epsilon^l in expansion
%   of the area (Eq. (65) expressed in terms of n and epsi).  n is a
%   scalar.  C4x is a 1 x 21 array.

  persistent coeff nC4 nC4x
  if isempty(coeff)
    nC4 = 6;
    nC4x = (nC4 * (nC4 + 1)) / 2;
    coeff = [ ...
        97, 15015, ...
        1088, 156, 45045, ...
        -224, -4784, 1573, 45045, ...
        -10656, 14144, -4576, -858, 45045, ...
        64, 624, -4576, 6864, -3003, 15015, ...
        100, 208, 572, 3432, -12012, 30030, 45045, ...
        1, 9009, ...
        -2944, 468, 135135, ...
        5792, 1040, -1287, 135135, ...
        5952, -11648, 9152, -2574, 135135, ...
        -64, -624, 4576, -6864, 3003, 135135, ...
        8, 10725, ...
        1856, -936, 225225, ...
        -8448, 4992, -1144, 225225, ...
        -1440, 4160, -4576, 1716, 225225, ...
        -136, 63063, ...
        1024, -208, 105105, ...
        3584, -3328, 1144, 315315, ...
        -128, 135135, ...
        -2560, 832, 405405, ...
        128, 99099, ...
            ];
  end
  C4x = zeros(1, nC4x);
  o = 1;
  k = 1;
  for l = 0 : nC4 - 1
    for j = nC4 - 1 : -1 : l
      m = nC4 - j - 1;
      C4x(k) = polyval(coeff(o : o + m), n) / coeff(o + m + 1);
      k = k + 1;
      o = o + m + 2;
    end
  end
end