rbmatlab 0.10.01
general/geometry/cubequadrature.m
Go to the documentation of this file.
00001 function res = cubequadrature(poldeg, func, varargin)
00002 %function res = cubequadrature(poldeg, func, varargin)
00003 % integration of function func over reference cube == unit cube.
00004 % by Gaussian quadrature exactly integrating polynoms of poldeg.
00005 %
00006 % arguments:
00007 %  poldeg:  degree of polynomial the quadrature rule exactly approximates
00008 %           (0-23)
00009 %  dim:     dimension of cube on which we want to integrate (>=2)
00010 %  func:    is a function getting a local coordinate vector (1d) and giving a
00011 %           (vectorial or scalar) result
00012 %  varargin: optional further arguments for function
00013 %
00014 % return values:
00015 %  res:     result of quadrature
00016 %
00017 
00018 [points, weights]= get_quadrature_weights_1d(poldeg);
00019 
00020 n = length(points);
00021 
00022 weightss = weights';
00023 pointss  = points;
00024 
00025 dim = 2;
00026 
00027 for i = 1:dim-1
00028   m = size(pointss,1);
00029   weightss = kron(weightss, weights);
00030   weightss = reshape(weightss, m*n, 1);
00031   pointss  = [repmat(pointss, n, 1), reshape(repmat(points,1,m)',n*m,1)];
00032 end
00033 
00034 res = quadrature(weightss,pointss,func,varargin{:});
00035 
All Classes Namespaces Files Functions Variables