function weight = gl_weights ( order )

%*****************************************************************************80
%
%% GL_WEIGHTS returns weights for certain Gauss-Legendre quadrature rules.
%
%  Discussion:
%
%    The allowed orders are 1, 3, 7, 15, 31, 63 or 127.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license. 
%
%  Modified:
%
%    02 October 2007
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Milton Abramowitz, Irene Stegun,
%    Handbook of Mathematical Functions,
%    National Bureau of Standards, 1964,
%    ISBN: 0-486-61272-4,
%    LC: QA47.A34.
%
%    Arthur Stroud, Don Secrest,
%    Gaussian Quadrature Formulas,
%    Prentice Hall, 1966,
%    LC: QA299.4G3S7.
%
%  Parameters:
%
%    Input, integer ORDER, the order of the rule.
%    ORDER must be 1, 3, 7, 15, 31, 63, or 127.
%
%    Output, real WEIGHT(ORDER), the weights.
%    The weights are positive, symmetric and should sum to 2.
%
  if ( order == 1 )

    weight(1) = 2.0E+00;

  elseif ( order == 3 )

    weight(1) = 0.555555555555555555555555555555E+00;
    weight(2) = 0.888888888888888888888888888888E+00;
    weight(3) = 0.555555555555555555555555555555E+00;

  elseif ( order == 7 )

    weight(1) = 0.129484966168869693270611432679E+00;
    weight(2) = 0.279705391489276667901467771424E+00;
    weight(3) = 0.381830050505118944950369775489E+00;
    weight(4) = 0.417959183673469387755102040816E+00;
    weight(5) = 0.381830050505118944950369775489E+00;
    weight(6) = 0.279705391489276667901467771424E+00;
    weight(7) = 0.129484966168869693270611432679E+00;

  elseif ( order == 15 )

    weight(1) =  0.307532419961172683546283935772E-01;
    weight(2) =  0.703660474881081247092674164507E-01;
    weight(3) =  0.107159220467171935011869546686E+00;
    weight(4) =  0.139570677926154314447804794511E+00;
    weight(5) =  0.166269205816993933553200860481E+00;
    weight(6) =  0.186161000015562211026800561866E+00;
    weight(7) =  0.198431485327111576456118326444E+00;
    weight(8) =  0.202578241925561272880620199968E+00;
    weight(9) =  0.198431485327111576456118326444E+00;
    weight(10) = 0.186161000015562211026800561866E+00;
    weight(11) = 0.166269205816993933553200860481E+00;
    weight(12) = 0.139570677926154314447804794511E+00;
    weight(13) = 0.107159220467171935011869546686E+00;
    weight(14) = 0.703660474881081247092674164507E-01;
    weight(15) = 0.307532419961172683546283935772E-01;

  elseif ( order == 31 )
 
    weight( 1) =   0.74708315792487746093913218970494E-02;
    weight( 2) =   0.17318620790310582463552990782414E-01;
    weight( 3) =   0.27009019184979421800608642617676E-01;
    weight( 4) =   0.36432273912385464024392008749009E-01;
    weight( 5) =   0.45493707527201102902315857856518E-01;
    weight( 6) =   0.54103082424916853711666259085477E-01;
    weight( 7) =   0.62174786561028426910343543686657E-01;
    weight( 8) =   0.69628583235410366167756126255124E-01;
    weight( 9) =   0.76390386598776616426357674901331E-01;
    weight(10) =   0.82392991761589263903823367431962E-01;
    weight(11) =   0.87576740608477876126198069695333E-01;
    weight(12) =   0.91890113893641478215362871607150E-01;
    weight(13) =   0.95290242912319512807204197487597E-01;
    weight(14) =   0.97743335386328725093474010978997E-01;
    weight(15) =   0.99225011226672307874875514428615E-01;
    weight(16) =   0.99720544793426451427533833734349E-01;
    weight(17) =   0.99225011226672307874875514428615E-01;
    weight(18) =   0.97743335386328725093474010978997E-01;
    weight(19) =   0.95290242912319512807204197487597E-01;
    weight(20) =   0.91890113893641478215362871607150E-01;
    weight(21) =   0.87576740608477876126198069695333E-01;
    weight(22) =   0.82392991761589263903823367431962E-01;
    weight(23) =   0.76390386598776616426357674901331E-01;
    weight(24) =   0.69628583235410366167756126255124E-01;
    weight(25) =   0.62174786561028426910343543686657E-01;
    weight(26) =   0.54103082424916853711666259085477E-01;
    weight(27) =   0.45493707527201102902315857856518E-01;
    weight(28) =   0.36432273912385464024392008749009E-01;
    weight(29) =   0.27009019184979421800608642617676E-01;
    weight(30) =   0.17318620790310582463552990782414E-01;
    weight(31) =   0.74708315792487746093913218970494E-02;

  elseif ( order == 63 )

    weight( 1) =   0.18398745955770837880499331680577E-02;
    weight( 2) =   0.42785083468637618661951422543371E-02;
    weight( 3) =   0.67102917659601362519069109850892E-02;
    weight( 4) =   0.91259686763266563540586445877022E-02;
    weight( 5) =   0.11519376076880041750750606118707E-01;
    weight( 6) =   0.13884612616115610824866086365937E-01;
    weight( 7) =   0.16215878410338338882283672974995E-01;
    weight( 8) =   0.18507464460161270409260545805144E-01;
    weight( 9) =   0.20753761258039090775341953421471E-01;
    weight(10) =   0.22949271004889933148942319561770E-01;
    weight(11) =   0.25088620553344986618630138068443E-01;
    weight(12) =   0.27166574359097933225189839439413E-01;
    weight(13) =   0.29178047208280526945551502154029E-01;
    weight(14) =   0.31118116622219817508215988557189E-01;
    weight(15) =   0.32982034883779341765683179672459E-01;
    weight(16) =   0.34765240645355877697180504642788E-01;
    weight(17) =   0.36463370085457289630452409787542E-01;
    weight(18) =   0.38072267584349556763638324927889E-01;
    weight(19) =   0.39587995891544093984807928149202E-01;
    weight(20) =   0.41006845759666398635110037009072E-01;
    weight(21) =   0.42325345020815822982505485403028E-01;
    weight(22) =   0.43540267083027590798964315704401E-01;
    weight(23) =   0.44648638825941395370332669516813E-01;
    weight(24) =   0.45647747876292608685885992608542E-01;
    weight(25) =   0.46535149245383696510395418746953E-01;
    weight(26) =   0.47308671312268919080604988338844E-01;
    weight(27) =   0.47966421137995131411052756195132E-01;
    weight(28) =   0.48506789097883847864090099145802E-01;
    weight(29) =   0.48928452820511989944709361549215E-01;
    weight(30) =   0.49230380423747560785043116988145E-01;
    weight(31) =   0.49411833039918178967039646116705E-01;
    weight(32) =   0.49472366623931020888669360420926E-01;
    weight(33) =   0.49411833039918178967039646116705E-01;
    weight(34) =   0.49230380423747560785043116988145E-01;
    weight(35) =   0.48928452820511989944709361549215E-01;
    weight(36) =   0.48506789097883847864090099145802E-01;
    weight(37) =   0.47966421137995131411052756195132E-01;
    weight(38) =   0.47308671312268919080604988338844E-01;
    weight(39) =   0.46535149245383696510395418746953E-01;
    weight(40) =   0.45647747876292608685885992608542E-01;
    weight(41) =   0.44648638825941395370332669516813E-01;
    weight(42) =   0.43540267083027590798964315704401E-01;
    weight(43) =   0.42325345020815822982505485403028E-01;
    weight(44) =   0.41006845759666398635110037009072E-01;
    weight(45) =   0.39587995891544093984807928149202E-01;
    weight(46) =   0.38072267584349556763638324927889E-01;
    weight(47) =   0.36463370085457289630452409787542E-01;
    weight(48) =   0.34765240645355877697180504642788E-01;
    weight(49) =   0.32982034883779341765683179672459E-01;
    weight(50) =   0.31118116622219817508215988557189E-01;
    weight(51) =   0.29178047208280526945551502154029E-01;
    weight(52) =   0.27166574359097933225189839439413E-01;
    weight(53) =   0.25088620553344986618630138068443E-01;
    weight(54) =   0.22949271004889933148942319561770E-01;
    weight(55) =   0.20753761258039090775341953421471E-01;
    weight(56) =   0.18507464460161270409260545805144E-01;
    weight(57) =   0.16215878410338338882283672974995E-01;
    weight(58) =   0.13884612616115610824866086365937E-01;
    weight(59) =   0.11519376076880041750750606118707E-01;
    weight(60) =   0.91259686763266563540586445877022E-02;
    weight(61) =   0.67102917659601362519069109850892E-02;
    weight(62) =   0.42785083468637618661951422543371E-02;
    weight(63) =   0.18398745955770837880499331680577E-02;
 
  elseif ( order == 127 )
  
    weight(  1) =   0.45645726109586654495731936146574E-03;
    weight(  2) =   0.10622766869538486959954760554099E-02;
    weight(  3) =   0.16683488125171936761028811985672E-02;
    weight(  4) =   0.22734860707492547802810838362671E-02;
    weight(  5) =   0.28772587656289004082883197417581E-02;
    weight(  6) =   0.34792893810051465908910894094105E-02;
    weight(  7) =   0.40792095178254605327114733456293E-02;
    weight(  8) =   0.46766539777779034772638165662478E-02;
    weight(  9) =   0.52712596565634400891303815906251E-02;
    weight( 10) =   0.58626653903523901033648343751367E-02;
    weight( 11) =   0.64505120486899171845442463868748E-02;
    weight( 12) =   0.70344427036681608755685893032552E-02;
    weight( 13) =   0.76141028256526859356393930849227E-02;
    weight( 14) =   0.81891404887415730817235884718726E-02;
    weight( 15) =   0.87592065795403145773316804234385E-02;
    weight( 16) =   0.93239550065309714787536985834029E-02;
    weight( 17) =   0.98830429087554914716648010899606E-02;
    weight( 18) =   0.10436130863141005225673171997668E-01;
    weight( 19) =   0.10982883090068975788799657376065E-01;
    weight( 20) =   0.11522967656921087154811609734510E-01;
    weight( 21) =   0.12056056679400848183529562144697E-01;
    weight( 22) =   0.12581826520465013101514365424172E-01;
    weight( 23) =   0.13099957986718627426172681912499E-01;
    weight( 24) =   0.13610136522139249906034237533759E-01;
    weight( 25) =   0.14112052399003395774044161633613E-01;
    weight( 26) =   0.14605400905893418351737288078952E-01;
    weight( 27) =   0.15089882532666922992635733981431E-01;
    weight( 28) =   0.15565203152273955098532590262975E-01;
    weight( 29) =   0.16031074199309941802254151842763E-01;
    weight( 30) =   0.16487212845194879399346060358146E-01;
    weight( 31) =   0.16933342169871654545878815295200E-01;
    weight( 32) =   0.17369191329918731922164721250350E-01;
    weight( 33) =   0.17794495722974774231027912900351E-01;
    weight( 34) =   0.18208997148375106468721469154479E-01;
    weight( 35) =   0.18612443963902310429440419898958E-01;
    weight( 36) =   0.19004591238555646611148901044533E-01;
    weight( 37) =   0.19385200901246454628112623489471E-01;
    weight( 38) =   0.19754041885329183081815217323169E-01;
    weight( 39) =   0.20110890268880247225644623956287E-01;
    weight( 40) =   0.20455529410639508279497065713301E-01;
    weight( 41) =   0.20787750081531811812652137291250E-01;
    weight( 42) =   0.21107350591688713643523847921658E-01;
    weight( 43) =   0.21414136912893259295449693233545E-01;
    weight( 44) =   0.21707922796373466052301324695331E-01;
    weight( 45) =   0.21988529885872983756478409758807E-01;
    weight( 46) =   0.22255787825930280235631416460158E-01;
    weight( 47) =   0.22509534365300608085694429903050E-01;
    weight( 48) =   0.22749615455457959852242553240982E-01;
    weight( 49) =   0.22975885344117206754377437838947E-01;
    weight( 50) =   0.23188206663719640249922582981729E-01;
    weight( 51) =   0.23386450514828194170722043496950E-01;
    weight( 52) =   0.23570496544381716050033676844306E-01;
    weight( 53) =   0.23740233018760777777714726703424E-01;
    weight( 54) =   0.23895556891620665983864481754172E-01;
    weight( 55) =   0.24036373866450369675132086026456E-01;
    weight( 56) =   0.24162598453819584716522917710986E-01;
    weight( 57) =   0.24274154023278979833195063936748E-01;
    weight( 58) =   0.24370972849882214952813561907241E-01;
    weight( 59) =   0.24452996155301467956140198471529E-01;
    weight( 60) =   0.24520174143511508275183033290175E-01;
    weight( 61) =   0.24572466031020653286354137335186E-01;
    weight( 62) =   0.24609840071630254092545634003360E-01;
    weight( 63) =   0.24632273575707679066033370218017E-01;
    weight( 64) =   0.24639752923961094419579417477503E-01;
    weight( 65) =   0.24632273575707679066033370218017E-01;
    weight( 66) =   0.24609840071630254092545634003360E-01;
    weight( 67) =   0.24572466031020653286354137335186E-01;
    weight( 68) =   0.24520174143511508275183033290175E-01;
    weight( 69) =   0.24452996155301467956140198471529E-01;
    weight( 70) =   0.24370972849882214952813561907241E-01;
    weight( 71) =   0.24274154023278979833195063936748E-01;
    weight( 72) =   0.24162598453819584716522917710986E-01;
    weight( 73) =   0.24036373866450369675132086026456E-01;
    weight( 74) =   0.23895556891620665983864481754172E-01;
    weight( 75) =   0.23740233018760777777714726703424E-01;
    weight( 76) =   0.23570496544381716050033676844306E-01;
    weight( 77) =   0.23386450514828194170722043496950E-01;
    weight( 78) =   0.23188206663719640249922582981729E-01;
    weight( 79) =   0.22975885344117206754377437838947E-01;
    weight( 80) =   0.22749615455457959852242553240982E-01;
    weight( 81) =   0.22509534365300608085694429903050E-01;
    weight( 82) =   0.22255787825930280235631416460158E-01;
    weight( 83) =   0.21988529885872983756478409758807E-01;
    weight( 84) =   0.21707922796373466052301324695331E-01;
    weight( 85) =   0.21414136912893259295449693233545E-01;
    weight( 86) =   0.21107350591688713643523847921658E-01;
    weight( 87) =   0.20787750081531811812652137291250E-01;
    weight( 88) =   0.20455529410639508279497065713301E-01;
    weight( 89) =   0.20110890268880247225644623956287E-01;
    weight( 90) =   0.19754041885329183081815217323169E-01;
    weight( 91) =   0.19385200901246454628112623489471E-01;
    weight( 92) =   0.19004591238555646611148901044533E-01;
    weight( 93) =   0.18612443963902310429440419898958E-01;
    weight( 94) =   0.18208997148375106468721469154479E-01;
    weight( 95) =   0.17794495722974774231027912900351E-01;
    weight( 96) =   0.17369191329918731922164721250350E-01;
    weight( 97) =   0.16933342169871654545878815295200E-01;
    weight( 98) =   0.16487212845194879399346060358146E-01;
    weight( 99) =   0.16031074199309941802254151842763E-01;
    weight(100) =   0.15565203152273955098532590262975E-01;
    weight(101) =   0.15089882532666922992635733981431E-01;
    weight(102) =   0.14605400905893418351737288078952E-01;
    weight(103) =   0.14112052399003395774044161633613E-01;
    weight(104) =   0.13610136522139249906034237533759E-01;
    weight(105) =   0.13099957986718627426172681912499E-01;
    weight(106) =   0.12581826520465013101514365424172E-01;
    weight(107) =   0.12056056679400848183529562144697E-01;
    weight(108) =   0.11522967656921087154811609734510E-01;
    weight(109) =   0.10982883090068975788799657376065E-01;
    weight(110) =   0.10436130863141005225673171997668E-01;
    weight(111) =   0.98830429087554914716648010899606E-02;
    weight(112) =   0.93239550065309714787536985834029E-02;
    weight(113) =   0.87592065795403145773316804234385E-02;
    weight(114) =   0.81891404887415730817235884718726E-02;
    weight(115) =   0.76141028256526859356393930849227E-02;
    weight(116) =   0.70344427036681608755685893032552E-02;
    weight(117) =   0.64505120486899171845442463868748E-02;
    weight(118) =   0.58626653903523901033648343751367E-02;
    weight(119) =   0.52712596565634400891303815906251E-02;
    weight(120) =   0.46766539777779034772638165662478E-02;
    weight(121) =   0.40792095178254605327114733456293E-02;
    weight(122) =   0.34792893810051465908910894094105E-02;
    weight(123) =   0.28772587656289004082883197417581E-02;
    weight(124) =   0.22734860707492547802810838362671E-02;
    weight(125) =   0.16683488125171936761028811985672E-02;
    weight(126) =   0.10622766869538486959954760554099E-02;
    weight(127) =   0.45645726109586654495731936146574E-03;
 
  else

    fprintf ( 1, '\n' );
    fprintf ( 1, 'GL_WEIGHTS - Fatal error!\n' );
    fprintf ( 1, '  Illegal value of ORDER = %d\n', order );
    fprintf ( 1, '  Legal values are 1, 3, 7, 15, 31, 63 or 127.\n' );
    error ( 'GL_WEIGHTS - Fatal error!' );

  end

  return
end
