function w = gpbaryw(level)
% GPBARYW   Get the 1D barycentric weights for the
% Gauss-Patterson grid.
	
% Author : Andreas Klimke
% Version: 1.0
% Date   : November 24, 2007

% ------------------------------------------------------------
% Sparse Grid Interpolation Toolbox
% Copyright (c) 2006 W. Andreas Klimke, Universitaet Stuttgart 
% Copyright (c) 2007-2008 W. A. Klimke. All Rights Reserved.
% See LICENSE.txt for license. 
% email: klimkeas@ians.uni-stuttgart.de
% web  : http://www.ians.uni-stuttgart.de/spinterp
% ------------------------------------------------------------

switch level
 case 0
	w = 1;
 case 1
  w = [0.5000000000000000e-0 -1.0000000000000000e-0];
 case 2
  w = [0.2389562399804650e-0 -0.6554465493910690e-0 ...
       0.9164903094106040e-0 -1.0000000000000000e-0];
 case 3
  w = [0.3085732742889269e-0 -0.7759609054034582e-0 ...
	     0.9730577082723834e-0 -1.0000000000000000e-0 ...
			 0.9651128023399624e-0 -0.9214581385020298e-0 ...
			 0.8904181282668750e-0 -0.8794857385253193e-0];
 case 4
  w = [0.4284765107713552e-0 -0.9674952645753376e-0 ...
	     1.0000000000000000e-0 -0.8073763738936263e-0 ...
	     0.5959019645796662e-0 -0.4284109973194455e-0 ...
			 0.3090233900161985e-0 -0.2271083041792955e-0 ...
       0.1715268309161644e-0 -0.1338120870473934e-0 ...
			 0.1081546364527703e-0 -0.9073420363174436e-1 ...
       0.7909270443820152e-1 -0.7168121786085341e-1 ...
			 0.6756488645338050e-1 -0.6624495024008108e-1];
 case 5
  w = [0.4761689774882791e-0 -1.0000000000000000e-0 ...
	     0.8951802743821745e-0 -0.5931880330727972e-0 ...
       0.3446713216950697e-0 -0.1887366139903847e-0 ...
			 0.1010026343422441e-0 -0.5391510866030504e-1 ...
       0.2905688513918218e-1 -0.1592647206003192e-1 ...
			 0.8917516424034839e-2 -0.5114369427222019e-2 ...
			 0.3009406140647174e-2 -0.1818655851124444e-2 ...
			 0.1129456765407580e-2 -0.7211000286455359e-3 ...
			 0.4733817579545664e-3 -0.3195580143057075e-3 ...
			 0.2218227922218166e-3 -0.1583257717017353e-3 ...
			 0.1161821456470950e-3 -0.8764186196347213e-4 ...
			 0.6795226274872346e-4 -0.5414390533152548e-4 ...
			 0.4432843387685334e-4 -0.3728544273524615e-4 ...
			 0.3221531510574336e-4 -0.2858909101688675e-4 ...
			 0.2605612252662254e-4 -0.2438687098702864e-4 ...
			 0.2343764915145207e-4 -0.2312961543917948e-4];
 case 6
  w = [0.4961729559598435e-0 -1.0000000000000000e-0 ...
	     0.8207381753150933e-0 -0.4792004570535736e-0 ...
	     0.2370422415813909e-0 -0.1072561730738105e-0 ...
			 0.4621060128445129e-1 -0.1940652396239318e-1 ...
			 0.8059646108315423e-2 -0.3341041271341492e-2 ...
			 0.1391076421696200e-2 -0.5842685337623964e-3 ...
			 0.2483284595990911e-3 -0.1070501794628850e-3 ...
			 0.4688369444739026e-4 -0.2088588637335537e-4 ...
			 0.9472111162631427e-5 -0.4375709775264854e-5 ...
			 0.2059732032056890e-5 -0.9881358613753917e-6 ...
			 0.4831683085525125e-6 -0.2407971733363551e-6 ...
			 0.1223052268446143e-6 -0.6330402849816564e-7 ...
			 0.3338496881971787e-7 -0.1793649137605078e-7 ...
			 0.9815684853054276e-8 -0.5470515716389574e-8 ...
			 0.3104474727365682e-8 -0.1793611788188222e-8 ...
			 0.1054820854605286e-8 -0.6313496351815102e-9 ...
			 0.3845341465065858e-9 -0.2382913467980216e-9 ...
			 0.1502195793889654e-9 -0.9632258977165985e-10 ...
			 0.6281356365121918e-10 -0.4165284046151541e-10 ...
			 0.2808315197701900e-10 -0.1924877719136859e-10 ...
			 0.1341110141171783e-10 -0.9496850740372480e-11 ...
			 0.6834400742017730e-11 -0.4997820893808907e-11 ...
			 0.3713437304234225e-11 -0.2803137557864015e-11 ...
			 0.2149539400208833e-11 -0.1674329496665498e-11 ...
			 0.1324630884002739e-11 -0.1064322552770007e-11 ...
			 0.8684488054281593e-12 -0.7195782254680809e-12 ...
			 0.6054064647792446e-12 -0.5171611918326179e-12 ...
			 0.4485298932818066e-12 -0.3949320660460756e-12 ...
			 0.3530206289342299e-12 -0.3203375146310410e-12 ...
			 0.2950741104537000e-12 -0.2759038562229908e-12 ...
			 0.2618651977225959e-12 -0.2522803113493657e-12 ...
			 0.2466998748736465e-12 -0.2448675056241474e-12];
 case 7
	error('MATLAB:spinterp:unsupportedWeights',['Maximum depth (level 6) ' ... 
	   'exceeded for barycentric weights of Gauss-Patterson grid.']);
end

if level > 0
	w = [w(1:end-1) fliplr(w)];
end
