Mercurial > fem-fenics-eugenio
annotate src/feval.cc @ 212:ca7eb016cf64
Extend feval function to support also passing the coordinates separately
as multiple arguments and evaluating the function at multiple
points at once. From Daniel Kraft.
author | gedeone-octave <marcovass89@hotmail.it> |
---|---|
date | Tue, 04 Mar 2014 12:09:26 +0000 |
parents | 66071811eef8 |
children | a28b50969020 |
rev | line source |
---|---|
212
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
1 /* |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
2 Copyright (C) 2013-2014 Marco Vassallo <gedeone-octave@users.sourceforge.net> |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
3 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
4 This program is free software; you can redistribute it and/or modify it under |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
5 the terms of the GNU General Public License as published by the Free Software |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
6 Foundation; either version 3 of the License, or (at your option) any later |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
7 version. |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
8 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
9 This program is distributed in the hope that it will be useful, but WITHOUT |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
12 details. |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
13 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
14 You should have received a copy of the GNU General Public License along with |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
15 this program; if not, see <http://www.gnu.org/licenses/>. |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
16 */ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
17 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
18 #include "function.h" |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
19 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
20 /** |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
21 * Internal helper routine to evaluate the given function at a single |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
22 * point (as Array<double>). Returned is the function value also as |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
23 * Array<double>, which gets stored into the given array. |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
24 * too, so that they don't have to be constructed. |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
25 * @param f Dolfin function handle to evaluate. |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
26 * @param pt Point where we want to evaluate f as Octave array of coordinates. |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
27 * @param res Store the value here, should already be of the correct size. |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
28 */ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
29 static void |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
30 evaluate (const dolfin::Function& f, const Array<double>& pt, |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
31 Array<double>& res) |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
32 { |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
33 Array<double>& ptNonconst = const_cast<Array<double>&> (pt); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
34 dolfin::Array<double> x(ptNonconst.length (), ptNonconst.fortran_vec ()); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
35 dolfin::Array<double> values(res.length (), res.fortran_vec ()); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
36 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
37 f.eval (values, x); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
38 } |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
39 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
40 DEFUN_DLD (feval, args, , "-*- texinfo -*-\n\ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
41 @deftypefn {Function File} {[@var{value}]} = \ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
42 feval (@var{function_name}, @var{Coordinate})\n\ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
43 @deftypefnx {Function File} {[@var{value}]} = \ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
44 feval (@var{function_name}, @var{x}, @var{y})\n\ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
45 @deftypefnx {Function File} {[@var{value}]} = \ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
46 feval (@var{function_name}, @var{x}, @var{y}, @var{z})\n\ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
47 Evaluate a function at a specific point of the domain and return the value. \n\ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
48 With only two arguments, @var{Coordinate} is assumed to be an array holding \n\ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
49 the coordinates of the point where the function should be evaluated. With \n\ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
50 three or more arguments, the coordinates are passed separately in @var{x}, \n\ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
51 @var{y} and optionally @var{z}. In the latter case and if the function \n\ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
52 returns scalar values, @var{x}, @var{y} and @var{z} may also be arrays to \n\ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
53 evaluate the function at multiple points at once.\n\ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
54 @seealso{Function}\n\ |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
55 @end deftypefn") |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
56 { |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
57 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
58 int nargin = args.length (); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
59 octave_value retval = 0; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
60 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
61 if (nargin < 2) |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
62 print_usage (); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
63 else |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
64 { |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
65 if (! function_type_loaded) |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
66 { |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
67 function::register_type (); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
68 function_type_loaded = true; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
69 mlock (); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
70 } |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
71 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
72 if (args(0).type_id () == function::static_type_id ()) |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
73 { |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
74 const function & fspo = |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
75 static_cast<const function&> (args(0).get_rep ()); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
76 const boost::shared_ptr<const dolfin::Function> |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
77 & f = fspo.get_pfun (); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
78 dim_vector dims; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
79 dims.resize (2); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
80 dims(0) = 1; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
81 dims(1) = f->value_dimension (0); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
82 Array<double> res(dims); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
83 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
84 if (nargin == 2) |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
85 { |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
86 Array<double> point = args(1).array_value (); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
87 if (!error_state) |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
88 { |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
89 evaluate (*f, point, res); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
90 retval = octave_value (res); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
91 } |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
92 } |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
93 else |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
94 { |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
95 dim_vector inDims; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
96 inDims.resize (2); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
97 inDims(0) = 1; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
98 inDims(1) = nargin - 1; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
99 Array<double> point(inDims); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
100 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
101 std::vector<Array<double> > coords; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
102 coords.reserve (inDims(1)); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
103 dim_vector argDims; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
104 for (unsigned i = 1; i < nargin; ++i) |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
105 { |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
106 coords.push_back (args(i).array_value ()); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
107 const dim_vector curDims = coords.back ().dims (); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
108 if (i > 1 && argDims != curDims) |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
109 { |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
110 error ("feval: coordinate dimensions mismatch"); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
111 break; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
112 } |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
113 argDims = curDims; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
114 } |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
115 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
116 if (res.nelem () != 1) |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
117 error ("feval: separate coordinate version only supported" |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
118 "for scalar functions"); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
119 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
120 if (!error_state) |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
121 { |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
122 Array<double> retValArray(argDims); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
123 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
124 for (size_t i = 0; i < retValArray.nelem (); ++i) |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
125 { |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
126 for (unsigned j = 0; j < coords.size (); ++j) |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
127 point(j) = coords[j].fortran_vec ()[i]; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
128 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
129 evaluate (*f, point, res); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
130 retValArray.fortran_vec ()[i] = res(0); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
131 } |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
132 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
133 retval = octave_value (retValArray); |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
134 } |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
135 } |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
136 } |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
137 } |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
138 |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
139 return retval; |
ca7eb016cf64
Extend feval function to support also passing the coordinates separately
gedeone-octave <marcovass89@hotmail.it>
parents:
184
diff
changeset
|
140 } |