Mercurial > repos > public > sbplib
comparison +grid/evalOn.m @ 810:77451445955f feature/poroelastic
Bugfix in grid/evalOn
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Fri, 27 Jul 2018 10:23:49 -0700 |
parents | 94f0f0b0d721 |
children |
comparison
equal
deleted
inserted
replaced
809:94f0f0b0d721 | 810:77451445955f |
---|---|
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) || nargin(func) < 0,'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 |