1 function res = quadrature(weights,points,func,varargin)
2 %
function res = quadrature(weights,points,func,varargin)
4 % integration of
function func by given quadrature. func
5 % is a
function getting a local coordinate vector and varargin
6 % and giving a (vectorial or scalar) result or a cell array of such.
7 % points is expected to be a npoints x dimpoint matrix
8 % result is the same size of f-evaluations.
9 % we emphasize, that also cell-array valued functions can be
10 % integrated (
for use in rb-methods)
12 % Bernard Haasdonk 27.8.2009
14 npoints = length(weights);
16 f = func(points(1,:));
20 f = func(points(qp,:));
21 res = res +weights(qp)*f;
25 for q = 1:length(f(:));
26 res{q} = weights(1)*f{q};
29 f = func(points(qp,:));
30 for q = 1:length(f(:));
31 res{q} = res{q} +weights(qp)*f{q};
35 else % not isempty varargin: same but different...
36 f = func(points(1,:),varargin{:});
40 f = func(points(qp,:),varargin{:});
41 res = res +weights(qp)*func(points(qp,:),varargin{:});
44 for q = 1:length(f(:));
45 res{q} = weights(1)*f{q};
48 f = func(points(qp,:),varargin{:});
49 for q = 1:length(f(:));
50 res{q} = res{q} +weights(qp)*f{q};