rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
cubequadrature.m
Go to the documentation of this file.
1 function res = cubequadrature(poldeg, func, varargin)
2 %function res = cubequadrature(poldeg, func, varargin)
3 % integration of function func over reference cube == unit cube.
4 % by Gaussian quadrature exactly integrating polynoms of poldeg.
5 %
6 % arguments:
7 % poldeg: degree of polynomial the quadrature rule exactly approximates
8 % (0-23)
9 % dim: dimension of cube on which we want to integrate (>=2)
10 % func: is a function getting a local coordinate vector (1d) and giving a
11 % (vectorial or scalar) result
12 % varargin: optional further arguments for function
13 %
14 % return values:
15 % res: result of quadrature
16 %
17 
18 [points, weights]= get_quadrature_weights_1d(poldeg);
19 
20 n = length(points);
21 
22 weightss = weights';
23 pointss = points;
24 
25 dim = 2;
26 
27 for i = 1:dim-1
28  m = size(pointss,1);
29  weightss = kron(weightss, weights);
30  weightss = reshape(weightss, m*n, 1);
31  pointss = [repmat(pointss, n, 1), reshape(repmat(points,1,m)',n*m,1)];
32 end
33 
34 res = quadrature(weightss,pointss,func,varargin{:});
35