
function [I,xw]=cubature_S2_rects_eval(f,n,x,str)

if nargin < 3
    str='better';
end

validStrings = {'classic','legendre','better','antigauss','antitrigauss',...
    'kronrod'};

if ( any(strcmpi(str, validStrings)) )
    
    [I,xw]=cubeval(f,n,x,str);
    
else
    
    [I,xw]=cubeval(f,n,x,'better');
    
end




function [I,xw]=cubeval(f,n,x,str)

[thetaw,xw]=cubature_S2_rects_nodes(x,n,str);

xx=xw(:,1); yy=xw(:,2); zz=xw(:,3); ww=xw(:,4); 
fx=feval(f,xx,yy,zz);
I=ww'*fx;
