rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
add_integral_kernels.m
Go to the documentation of this file.
1 function res = add_integral_kernels(kernels, varargin)
2 %function res = add_integral_kernels(kernels, varargin)
3 % Addition of integral kernel evaluations
4 %
5 % Integral kernels are evaluated at the same arguments and the
6 % results are added up. If the results are cell arrays, they are
7 % concatenated. This function is used in Fem.Assembly.operator().
8 %
9 % Parameters:
10 % kernels: cell array containing function handles corresponding to
11 % Fem integral kernels.
12 % varargin: inputs for the integral kernels as variable-length
13 % input argument list.
14 %
15 % Return values:
16 % res: result of addition or cell concatenation.
17 
18 res_tmp = cell(1, length(kernels));
19 
20 for q = 1:length(kernels)
21 
22  res_tmp{q} = kernels{q}(varargin{:});
23 end
24 
25 if iscell(res_tmp{1})
26  for q = 1:length(res_tmp)
27  res_tmp{q} = res_tmp{q}(:)';
28  end
29 
30  res = [res_tmp{:}];
31 else
32 
33  res = res_tmp{1};
34  for q = 2:length(res_tmp)
35  res = res + res_tmp{q};
36  end
37 end
38 
39 end