Mercurial > repos > public > sbplib
comparison +grid/evalOn.m @ 1071:92cb03e64ca4 feature/grids/LaplaceSquared
Merge with default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 20 Sep 2018 12:05:20 +0200 |
parents | 77451445955f |
children |
comparison
equal
deleted
inserted
replaced
1070:f6b3af6febf3 | 1071:92cb03e64ca4 |
---|---|
11 | 11 |
12 gf = repmat(func,[g.N, 1]); | 12 gf = repmat(func,[g.N, 1]); |
13 return | 13 return |
14 end | 14 end |
15 % func should now be a function_handle | 15 % func should now be a function_handle |
16 assert(g.D == nargin(func),'grid:evalOn:WrongNumberOfInputs', 'The number of inputs of the function must match the dimension of the domain.') | 16 assert(g.D == nargin(func) || nargin(func) < 0,'grid:evalOn:WrongNumberOfInputs', 'The number of inputs of the function must match the dimension of the domain.') |
17 | 17 |
18 x = num2cell(g.points(),1); | 18 x = num2cell(g.points(),1); |
19 k = numberOfComponents(func); | 19 k = numberOfComponents(func, g.D); |
20 | 20 |
21 gf = func(x{:}); | 21 gf = func(x{:}); |
22 gf = reorderComponents(gf, k); | 22 gf = reorderComponents(gf, k); |
23 end | 23 end |
24 | 24 |
25 % Find the number of vector components of func | 25 % Find the number of vector components of func |
26 function k = numberOfComponents(func) | 26 function k = numberOfComponents(func, dim) |
27 x0 = num2cell(ones(1,nargin(func))); | 27 x0 = num2cell(ones(1, dim)); |
28 f0 = func(x0{:}); | 28 f0 = func(x0{:}); |
29 assert(size(f0,2) == 1, 'grid:evalOn:VectorValuedWrongDim', 'A vector valued function must be given as a column vector'); | 29 assert(size(f0,2) == 1, 'grid:evalOn:VectorValuedWrongDim', 'A vector valued function must be given as a column vector'); |
30 k = length(f0); | 30 k = length(f0); |
31 end | 31 end |
32 | 32 |