function [ x, w ] = kpu ( l )

%*****************************************************************************80
%
%% KPU provides data for Kronrod-Patterson quadrature with a uniform weight.
%
%  Discussion:
%
%    This data assumes integration over the interval [0,1] with 
%    weight function w(x) = 1.
%
%    The rules listed are the standard Gauss-Patterson rules, but they are 
%    indexed in such a way that the L-th rule is the lowest order rule which
%    has polynomial precision of at least 2*L-1.  This means that a given
%    rule may be listed several times, since the precision of successive 
%    rules generally increases by more than 2.
%
%    For all orders L, the rule is formed by
%      X(1) with weight W(1),
%      X(2) and 1-X(2) with weight W(2),
%      X(3) and 1-X(3) with weight W(3) and so on.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    21 February 2014
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Florian Heiss, Viktor Winschel,
%    Likelihood approximation by numerical integration on sparse grids,
%    Journal of Econometrics,
%    Volume 144, 2008, pages 62-80.
%
%    Thomas Patterson,
%    The optimal addition of points to quadrature formulae,
%    Mathematics of Computation,
%    Volume 22, Number 104, October 1968, pages 847-856.
%
%    Knut Petras,
%    Smolyak Cubature of Given Polynomial Degree with Few Nodes
%    for Increasing Dimension,
%    Numerische Mathematik,
%    Volume 93, Number 4, February 2003, pages 729-753.
%
%  Parameters:
%
%    Input, integer L, the level of the rule.
%    1 <= L <= 25.
%
%    Output, real X(*), the nodes.
%
%    Output, real W(*), the weights.
%
  if ( l == 1 )
    x = [ ...
      0.0000000 ];
    w = [ ...
      2.0000000 ];
  elseif ( l <= 3 )
    x = [ ...
     0.0; ...
     0.77459666924148337704 ];
    w = [ ...
     0.888888888888888888889; ...
     0.555555555555555555556 ];
  elseif ( l <= 6 )
    x = [ ...
     0.0; ...
     0.43424374934680255800; ...
     0.77459666924148337704; ...
     0.96049126870802028342 ];
    w = [ ...
     0.450916538658474142345; ...
     0.401397414775962222905; ...
     0.268488089868333440729; ...
     0.104656226026467265194 ];
  elseif ( l <= 12 )
    x = [ ...
     0.0; ...
     0.22338668642896688163; ...
     0.43424374934680255800; ...
     0.62110294673722640294; ...
     0.77459666924148337704; ...
     0.88845923287225699889; ...
     0.96049126870802028342; ...
     0.99383196321275502221 ];
    w = [ ...
     0.225510499798206687386; ...
     0.219156858401587496404; ...
     0.200628529376989021034; ...
     0.171511909136391380787; ...
     0.134415255243784220360; ...
     0.0929271953151245376859; ...
     0.0516032829970797396969; ...
     0.0170017196299402603390 ];
  elseif ( l <= 24 )
    x = [ ...
     0.0; ...
     0.11248894313318662575; ...
     0.22338668642896688163; ...
     0.33113539325797683309; ...
     0.43424374934680255800; ...
     0.53131974364437562397; ...
     0.62110294673722640294; ...
     0.70249620649152707861; ...
     0.77459666924148337704; ...
     0.83672593816886873550; ...
     0.88845923287225699889; ...
     0.92965485742974005667; ...
     0.96049126870802028342; ...
     0.98153114955374010687; ...
     0.99383196321275502221; ...
     0.99909812496766759766 ];
    w = [ ...
     0.112755256720768691607; ...
     0.111956873020953456880; ...
     0.109578421055924638237; ...
     0.105669893580234809744; ...
     0.100314278611795578771; ...
     0.0936271099812644736167; ...
     0.0857559200499903511542; ...
     0.0768796204990035310427; ...
     0.0672077542959907035404; ...
     0.0569795094941233574122; ...
     0.0464628932617579865414; ...
     0.0359571033071293220968; ...
     0.0258075980961766535646; ...
     0.0164460498543878109338; ...
     0.00843456573932110624631; ...
     0.00254478079156187441540 ];
  elseif ( l == 25 )
    x = [ ...
     0.0; ...
     0.056344313046592789972; ...
     0.11248894313318662575; ...
     0.16823525155220746498; ...
     0.22338668642896688163; ...
     0.27774982202182431507; ...
     0.33113539325797683309; ...
     0.38335932419873034692; ...
     0.43424374934680255800; ...
     0.48361802694584102756; ...
     0.53131974364437562397; ...
     0.57719571005204581484; ...
     0.62110294673722640294; ...
     0.66290966002478059546; ...
     0.70249620649152707861; ...
     0.73975604435269475868; ...
     0.77459666924148337704; ...
     0.80694053195021761186; ...
     0.83672593816886873550; ...
     0.86390793819369047715; ...
     0.88845923287225699889; ...
     0.91037115695700429250; ...
     0.92965485742974005667; ...
     0.94634285837340290515; ...
     0.96049126870802028342; ...
     0.97218287474858179658; ...
     0.98153114955374010687; ...
     0.98868475754742947994; ...
     0.99383196321275502221; ...
     0.99720625937222195908; ...
     0.99909812496766759766; ...
     0.99987288812035761194 ];
    w = [ ...
     0.0563776283603847173877; ...
     0.0562776998312543012726; ...
     0.0559784365104763194076; ...
     0.0554814043565593639878; ...
     0.0547892105279628650322; ...
     0.0539054993352660639269; ...
     0.0528349467901165198621; ...
     0.0515832539520484587768; ...
     0.0501571393058995374137; ...
     0.0485643304066731987159; ...
     0.0468135549906280124026; ...
     0.0449145316536321974143; ...
     0.0428779600250077344929; ...
     0.0407155101169443189339; ...
     0.0384398102494555320386; ...
     0.0360644327807825726401; ...
     0.0336038771482077305417; ...
     0.0310735511116879648799; ...
     0.0284897547458335486125; ...
     0.0258696793272147469108; ...
     0.0232314466399102694433; ...
     0.0205942339159127111492; ...
     0.0179785515681282703329; ...
     0.0154067504665594978021; ...
     0.0129038001003512656260; ...
     0.0104982469096213218983; ...
     0.00822300795723592966926; ...
     0.00611550682211724633968; ...
     0.00421763044155885483908; ...
     0.00257904979468568827243; ...
     0.00126515655623006801137; ...
     0.000363221481845530659694 ];
  else
    x = [];
    w = [];
    fprintf ( 1, '\n' );
    fprintf ( 1, 'KPU - Fatal error!\n' );
    fprintf ( 1, '  Value of L must be between 1 and 25.\n' );
    error ( 'KPU - Fatal error!' );
  end
%
%  The rule as stored is for the interval [-1,+1].
%  Adjust it to the interval [0,1].
%
  n = length ( x );

  [ x, w ] = rule_adjust ( -1.0, +1.0, 0.0, +1.0, n, x, w );

  return
end
