1 |
jgs |
94 |
// $Id$ |
2 |
jgs |
121 |
/* |
3 |
elspeth |
615 |
************************************************************ |
4 |
|
|
* Copyright 2006 by ACcESS MNRF * |
5 |
|
|
* * |
6 |
|
|
* http://www.access.edu.au * |
7 |
|
|
* Primary Business: Queensland, Australia * |
8 |
|
|
* Licensed under the Open Software License version 3.0 * |
9 |
|
|
* http://www.opensource.org/licenses/osl-3.0.php * |
10 |
|
|
* * |
11 |
|
|
************************************************************ |
12 |
jgs |
121 |
*/ |
13 |
jgs |
94 |
|
14 |
jgs |
121 |
/** \file Data.h */ |
15 |
jgs |
94 |
|
16 |
|
|
#ifndef DATA_H |
17 |
|
|
#define DATA_H |
18 |
woo409 |
757 |
#include "system_dep.h" |
19 |
jgs |
94 |
|
20 |
jgs |
474 |
#include "DataAbstract.h" |
21 |
|
|
#include "DataAlgorithm.h" |
22 |
|
|
#include "FunctionSpace.h" |
23 |
|
|
#include "BinaryOp.h" |
24 |
|
|
#include "UnaryOp.h" |
25 |
|
|
#include "DataException.h" |
26 |
jgs |
94 |
|
27 |
|
|
extern "C" { |
28 |
jgs |
474 |
#include "DataC.h" |
29 |
woo409 |
757 |
#include "paso/Paso.h" |
30 |
jgs |
94 |
} |
31 |
|
|
|
32 |
bcumming |
790 |
#ifndef PASO_MPI |
33 |
|
|
#define MPI_Comm long |
34 |
|
|
#endif |
35 |
|
|
|
36 |
jgs |
94 |
#include <string> |
37 |
|
|
#include <algorithm> |
38 |
|
|
|
39 |
|
|
#include <boost/shared_ptr.hpp> |
40 |
|
|
#include <boost/python/object.hpp> |
41 |
|
|
#include <boost/python/tuple.hpp> |
42 |
|
|
#include <boost/python/numeric.hpp> |
43 |
|
|
|
44 |
jgs |
121 |
namespace escript { |
45 |
|
|
|
46 |
|
|
// |
47 |
jgs |
149 |
// Forward declaration for various implementations of Data. |
48 |
jgs |
121 |
class DataConstant; |
49 |
|
|
class DataTagged; |
50 |
|
|
class DataExpanded; |
51 |
|
|
|
52 |
jgs |
94 |
/** |
53 |
|
|
\brief |
54 |
jgs |
121 |
Data creates the appropriate Data object for the given construction |
55 |
|
|
arguments. |
56 |
jgs |
94 |
|
57 |
|
|
Description: |
58 |
|
|
Data is essentially a factory class which creates the appropriate Data |
59 |
|
|
object for the given construction arguments. It retains control over |
60 |
|
|
the object created for the lifetime of the object. |
61 |
|
|
The type of Data object referred to may change during the lifetime of |
62 |
|
|
the Data object. |
63 |
|
|
*/ |
64 |
|
|
class Data { |
65 |
|
|
|
66 |
|
|
public: |
67 |
|
|
|
68 |
jgs |
110 |
// These typedefs allow function names to be cast to pointers |
69 |
|
|
// to functions of the appropriate type when calling unaryOp etc. |
70 |
jgs |
94 |
typedef double (*UnaryDFunPtr)(double); |
71 |
|
|
typedef double (*BinaryDFunPtr)(double,double); |
72 |
|
|
|
73 |
gross |
854 |
|
74 |
jgs |
94 |
/** |
75 |
jgs |
102 |
Constructors. |
76 |
|
|
*/ |
77 |
|
|
|
78 |
|
|
/** |
79 |
jgs |
94 |
\brief |
80 |
|
|
Default constructor. |
81 |
|
|
Creates a DataEmpty object. |
82 |
|
|
*/ |
83 |
woo409 |
757 |
ESCRIPT_DLL_API |
84 |
jgs |
94 |
Data(); |
85 |
|
|
|
86 |
|
|
/** |
87 |
|
|
\brief |
88 |
|
|
Copy constructor. |
89 |
|
|
WARNING: Only performs a shallow copy. |
90 |
|
|
*/ |
91 |
woo409 |
757 |
ESCRIPT_DLL_API |
92 |
jgs |
94 |
Data(const Data& inData); |
93 |
|
|
|
94 |
|
|
/** |
95 |
|
|
\brief |
96 |
|
|
Constructor from another Data object. If "what" is different from the |
97 |
jgs |
102 |
function space of inData the inData are tried to be interpolated to what, |
98 |
jgs |
94 |
otherwise a shallow copy of inData is returned. |
99 |
|
|
*/ |
100 |
woo409 |
757 |
ESCRIPT_DLL_API |
101 |
jgs |
94 |
Data(const Data& inData, |
102 |
|
|
const FunctionSpace& what); |
103 |
|
|
|
104 |
|
|
/** |
105 |
|
|
\brief |
106 |
|
|
Constructor which copies data from a DataArrayView. |
107 |
|
|
|
108 |
|
|
\param value - Input - Data value for a single point. |
109 |
|
|
\param what - Input - A description of what this data represents. |
110 |
|
|
\param expanded - Input - Flag, if true fill the entire container with |
111 |
|
|
the value. Otherwise a more efficient storage |
112 |
|
|
mechanism will be used. |
113 |
|
|
*/ |
114 |
woo409 |
757 |
ESCRIPT_DLL_API |
115 |
jgs |
94 |
Data(const DataArrayView& value, |
116 |
|
|
const FunctionSpace& what=FunctionSpace(), |
117 |
|
|
bool expanded=false); |
118 |
|
|
|
119 |
|
|
/** |
120 |
|
|
\brief |
121 |
|
|
Constructor which creates a Data from a DataArrayView shape. |
122 |
|
|
|
123 |
|
|
\param value - Input - Single value applied to all Data. |
124 |
|
|
\param dataPointShape - Input - The shape of each data point. |
125 |
|
|
\param what - Input - A description of what this data represents. |
126 |
|
|
\param expanded - Input - Flag, if true fill the entire container with |
127 |
|
|
the given value. Otherwise a more efficient storage |
128 |
|
|
mechanism will be used. |
129 |
|
|
*/ |
130 |
woo409 |
757 |
ESCRIPT_DLL_API |
131 |
jgs |
94 |
Data(double value, |
132 |
|
|
const DataArrayView::ShapeType& dataPointShape=DataArrayView::ShapeType(), |
133 |
|
|
const FunctionSpace& what=FunctionSpace(), |
134 |
|
|
bool expanded=false); |
135 |
|
|
|
136 |
|
|
/** |
137 |
|
|
\brief |
138 |
|
|
Constructor which performs a deep copy of a region from another Data object. |
139 |
|
|
|
140 |
|
|
\param inData - Input - Input Data object. |
141 |
|
|
\param region - Input - Region to copy. |
142 |
|
|
*/ |
143 |
woo409 |
757 |
ESCRIPT_DLL_API |
144 |
jgs |
94 |
Data(const Data& inData, |
145 |
|
|
const DataArrayView::RegionType& region); |
146 |
|
|
|
147 |
|
|
/** |
148 |
|
|
\brief |
149 |
|
|
Constructor which will create Tagged data if expanded is false. |
150 |
|
|
No attempt is made to ensure the tag keys match the tag keys |
151 |
|
|
within the function space. |
152 |
|
|
|
153 |
|
|
\param tagKeys - Input - List of tag values. |
154 |
|
|
\param values - Input - List of values, one for each tag. |
155 |
|
|
\param defaultValue - Input - A default value, used if tag doesn't exist. |
156 |
|
|
\param what - Input - A description of what this data represents. |
157 |
|
|
\param expanded - Input - Flag, if true fill the entire container with |
158 |
|
|
the appropriate values. |
159 |
jgs |
544 |
==>* |
160 |
jgs |
94 |
*/ |
161 |
woo409 |
757 |
ESCRIPT_DLL_API |
162 |
jgs |
94 |
Data(const DataTagged::TagListType& tagKeys, |
163 |
|
|
const DataTagged::ValueListType& values, |
164 |
|
|
const DataArrayView& defaultValue, |
165 |
|
|
const FunctionSpace& what=FunctionSpace(), |
166 |
|
|
bool expanded=false); |
167 |
|
|
|
168 |
|
|
/** |
169 |
|
|
\brief |
170 |
|
|
Constructor which copies data from a python numarray. |
171 |
|
|
|
172 |
|
|
\param value - Input - Data value for a single point. |
173 |
|
|
\param what - Input - A description of what this data represents. |
174 |
|
|
\param expanded - Input - Flag, if true fill the entire container with |
175 |
|
|
the value. Otherwise a more efficient storage |
176 |
|
|
mechanism will be used. |
177 |
|
|
*/ |
178 |
woo409 |
757 |
ESCRIPT_DLL_API |
179 |
jgs |
94 |
Data(const boost::python::numeric::array& value, |
180 |
|
|
const FunctionSpace& what=FunctionSpace(), |
181 |
|
|
bool expanded=false); |
182 |
|
|
|
183 |
|
|
/** |
184 |
|
|
\brief |
185 |
|
|
Constructor which copies data from any object that can be converted into |
186 |
|
|
a python numarray. |
187 |
|
|
|
188 |
|
|
\param value - Input - Input data. |
189 |
|
|
\param what - Input - A description of what this data represents. |
190 |
|
|
\param expanded - Input - Flag, if true fill the entire container with |
191 |
|
|
the value. Otherwise a more efficient storage |
192 |
|
|
mechanism will be used. |
193 |
|
|
*/ |
194 |
woo409 |
757 |
ESCRIPT_DLL_API |
195 |
jgs |
94 |
Data(const boost::python::object& value, |
196 |
|
|
const FunctionSpace& what=FunctionSpace(), |
197 |
|
|
bool expanded=false); |
198 |
|
|
|
199 |
|
|
/** |
200 |
|
|
\brief |
201 |
|
|
Constructor which creates a DataConstant. |
202 |
|
|
Copies data from any object that can be converted |
203 |
|
|
into a numarray. All other parameters are copied from other. |
204 |
|
|
|
205 |
|
|
\param value - Input - Input data. |
206 |
|
|
\param other - Input - contains all other parameters. |
207 |
|
|
*/ |
208 |
woo409 |
757 |
ESCRIPT_DLL_API |
209 |
jgs |
94 |
Data(const boost::python::object& value, |
210 |
|
|
const Data& other); |
211 |
|
|
|
212 |
|
|
/** |
213 |
|
|
\brief |
214 |
|
|
Constructor which creates a DataConstant of "shape" with constant value. |
215 |
|
|
*/ |
216 |
woo409 |
757 |
ESCRIPT_DLL_API |
217 |
jgs |
94 |
Data(double value, |
218 |
|
|
const boost::python::tuple& shape=boost::python::make_tuple(), |
219 |
|
|
const FunctionSpace& what=FunctionSpace(), |
220 |
|
|
bool expanded=false); |
221 |
jgs |
151 |
/** |
222 |
|
|
\brief |
223 |
|
|
Destructor |
224 |
|
|
*/ |
225 |
woo409 |
757 |
ESCRIPT_DLL_API |
226 |
jgs |
151 |
~Data(); |
227 |
jgs |
94 |
|
228 |
|
|
/** |
229 |
|
|
\brief |
230 |
jgs |
102 |
Perform a deep copy. |
231 |
jgs |
94 |
*/ |
232 |
woo409 |
757 |
ESCRIPT_DLL_API |
233 |
jgs |
94 |
void |
234 |
jgs |
102 |
copy(const Data& other); |
235 |
jgs |
94 |
|
236 |
|
|
/** |
237 |
jgs |
102 |
Member access methods. |
238 |
jgs |
94 |
*/ |
239 |
|
|
|
240 |
|
|
/** |
241 |
|
|
\brief |
242 |
gross |
783 |
switches on update protection |
243 |
|
|
|
244 |
|
|
*/ |
245 |
|
|
ESCRIPT_DLL_API |
246 |
|
|
void |
247 |
|
|
setProtection(); |
248 |
|
|
|
249 |
|
|
/** |
250 |
|
|
\brief |
251 |
|
|
Returns trueif the data object is protected against update |
252 |
|
|
|
253 |
|
|
*/ |
254 |
|
|
ESCRIPT_DLL_API |
255 |
|
|
bool |
256 |
|
|
isProtected() const; |
257 |
|
|
/** |
258 |
|
|
\brief |
259 |
jgs |
121 |
Return the values of all data-points as a single python numarray object. |
260 |
jgs |
117 |
*/ |
261 |
woo409 |
757 |
ESCRIPT_DLL_API |
262 |
jgs |
121 |
const boost::python::numeric::array |
263 |
jgs |
117 |
convertToNumArray(); |
264 |
|
|
|
265 |
|
|
/** |
266 |
|
|
\brief |
267 |
jgs |
121 |
Return the values of all data-points for the given sample as a single python numarray object. |
268 |
|
|
*/ |
269 |
woo409 |
757 |
ESCRIPT_DLL_API |
270 |
jgs |
121 |
const boost::python::numeric::array |
271 |
|
|
convertToNumArrayFromSampleNo(int sampleNo); |
272 |
|
|
|
273 |
|
|
/** |
274 |
|
|
\brief |
275 |
|
|
Return the value of the specified data-point as a single python numarray object. |
276 |
|
|
*/ |
277 |
dhawcroft |
789 |
#ifndef PASO_MPI |
278 |
woo409 |
757 |
ESCRIPT_DLL_API |
279 |
jgs |
121 |
const boost::python::numeric::array |
280 |
bcumming |
790 |
convertToNumArrayFromDPNo(int ProcNo, |
281 |
|
|
int sampleNo, |
282 |
jgs |
121 |
int dataPointNo); |
283 |
dhawcroft |
789 |
#else |
284 |
|
|
ESCRIPT_DLL_API |
285 |
|
|
const boost::python::numeric::array |
286 |
|
|
convertToNumArrayFromDPNo(int procNo, |
287 |
|
|
int sampleNo, |
288 |
|
|
int dataPointNo); |
289 |
|
|
#endif |
290 |
jgs |
121 |
|
291 |
dhawcroft |
789 |
|
292 |
jgs |
121 |
/** |
293 |
|
|
\brief |
294 |
jgs |
149 |
Fills the expanded Data object from values of a python numarray object. |
295 |
|
|
*/ |
296 |
woo409 |
757 |
ESCRIPT_DLL_API |
297 |
jgs |
149 |
void |
298 |
|
|
fillFromNumArray(const boost::python::numeric::array); |
299 |
|
|
|
300 |
|
|
/** |
301 |
|
|
\brief |
302 |
|
|
Return the tag number associated with the given data-point. |
303 |
|
|
|
304 |
|
|
The data-point number here corresponds to the data-point number in the |
305 |
|
|
numarray returned by convertToNumArray. |
306 |
|
|
*/ |
307 |
woo409 |
757 |
ESCRIPT_DLL_API |
308 |
jgs |
149 |
int |
309 |
|
|
getTagNumber(int dpno); |
310 |
|
|
|
311 |
|
|
/** |
312 |
|
|
\brief |
313 |
jgs |
94 |
Return the C wrapper for the Data object. |
314 |
|
|
*/ |
315 |
woo409 |
757 |
ESCRIPT_DLL_API |
316 |
jgs |
102 |
escriptDataC |
317 |
|
|
getDataC(); |
318 |
jgs |
94 |
|
319 |
|
|
/** |
320 |
|
|
\brief |
321 |
|
|
Return the C wrapper for the Data object - const version. |
322 |
|
|
*/ |
323 |
woo409 |
757 |
ESCRIPT_DLL_API |
324 |
jgs |
102 |
escriptDataC |
325 |
|
|
getDataC() const; |
326 |
jgs |
94 |
|
327 |
|
|
/** |
328 |
|
|
\brief |
329 |
|
|
Write the data as a string. |
330 |
|
|
*/ |
331 |
woo409 |
757 |
ESCRIPT_DLL_API |
332 |
jgs |
102 |
inline |
333 |
|
|
std::string |
334 |
|
|
toString() const |
335 |
|
|
{ |
336 |
|
|
return m_data->toString(); |
337 |
|
|
} |
338 |
jgs |
94 |
|
339 |
|
|
/** |
340 |
|
|
\brief |
341 |
|
|
Return the DataArrayView of the point data. This essentially contains |
342 |
|
|
the shape information for each data point although it also may be used |
343 |
|
|
to manipulate the point data. |
344 |
|
|
*/ |
345 |
woo409 |
757 |
ESCRIPT_DLL_API |
346 |
jgs |
94 |
inline |
347 |
|
|
const DataArrayView& |
348 |
|
|
getPointDataView() const |
349 |
|
|
{ |
350 |
|
|
return m_data->getPointDataView(); |
351 |
|
|
} |
352 |
|
|
|
353 |
|
|
/** |
354 |
|
|
\brief |
355 |
jgs |
102 |
Whatever the current Data type make this into a DataExpanded. |
356 |
jgs |
94 |
*/ |
357 |
woo409 |
757 |
ESCRIPT_DLL_API |
358 |
jgs |
94 |
void |
359 |
|
|
expand(); |
360 |
|
|
|
361 |
|
|
/** |
362 |
|
|
\brief |
363 |
jgs |
102 |
If possible convert this Data to DataTagged. This will only allow |
364 |
jgs |
94 |
Constant data to be converted to tagged. An attempt to convert |
365 |
|
|
Expanded data to tagged will throw an exception. |
366 |
jgs |
544 |
==>* |
367 |
jgs |
94 |
*/ |
368 |
woo409 |
757 |
ESCRIPT_DLL_API |
369 |
jgs |
94 |
void |
370 |
|
|
tag(); |
371 |
|
|
|
372 |
|
|
/** |
373 |
|
|
\brief |
374 |
|
|
Return true if this Data is expanded. |
375 |
|
|
*/ |
376 |
woo409 |
757 |
ESCRIPT_DLL_API |
377 |
jgs |
94 |
bool |
378 |
|
|
isExpanded() const; |
379 |
|
|
|
380 |
|
|
/** |
381 |
|
|
\brief |
382 |
|
|
Return true if this Data is tagged. |
383 |
|
|
*/ |
384 |
woo409 |
757 |
ESCRIPT_DLL_API |
385 |
jgs |
94 |
bool |
386 |
|
|
isTagged() const; |
387 |
|
|
|
388 |
|
|
/** |
389 |
|
|
\brief |
390 |
jgs |
102 |
Return true if this Data is constant. |
391 |
jgs |
94 |
*/ |
392 |
woo409 |
757 |
ESCRIPT_DLL_API |
393 |
jgs |
94 |
bool |
394 |
jgs |
102 |
isConstant() const; |
395 |
jgs |
94 |
|
396 |
|
|
/** |
397 |
|
|
\brief |
398 |
jgs |
102 |
Return true if this Data is empty. |
399 |
jgs |
94 |
*/ |
400 |
woo409 |
757 |
ESCRIPT_DLL_API |
401 |
jgs |
94 |
bool |
402 |
jgs |
102 |
isEmpty() const; |
403 |
jgs |
94 |
|
404 |
|
|
/** |
405 |
|
|
\brief |
406 |
|
|
Return the function space. |
407 |
|
|
*/ |
408 |
woo409 |
757 |
ESCRIPT_DLL_API |
409 |
jgs |
94 |
inline |
410 |
|
|
const FunctionSpace& |
411 |
|
|
getFunctionSpace() const |
412 |
|
|
{ |
413 |
|
|
return m_data->getFunctionSpace(); |
414 |
|
|
} |
415 |
|
|
|
416 |
|
|
/** |
417 |
|
|
\brief |
418 |
|
|
Return a copy of the function space. |
419 |
|
|
*/ |
420 |
woo409 |
757 |
ESCRIPT_DLL_API |
421 |
jgs |
94 |
const FunctionSpace |
422 |
|
|
getCopyOfFunctionSpace() const; |
423 |
|
|
|
424 |
|
|
/** |
425 |
|
|
\brief |
426 |
|
|
Return the domain. |
427 |
|
|
*/ |
428 |
woo409 |
757 |
ESCRIPT_DLL_API |
429 |
jgs |
94 |
inline |
430 |
|
|
const AbstractDomain& |
431 |
|
|
getDomain() const |
432 |
|
|
{ |
433 |
|
|
return getFunctionSpace().getDomain(); |
434 |
|
|
} |
435 |
|
|
|
436 |
|
|
/** |
437 |
|
|
\brief |
438 |
|
|
Return a copy of the domain. |
439 |
|
|
*/ |
440 |
woo409 |
757 |
ESCRIPT_DLL_API |
441 |
jgs |
94 |
const AbstractDomain |
442 |
|
|
getCopyOfDomain() const; |
443 |
|
|
|
444 |
|
|
/** |
445 |
|
|
\brief |
446 |
|
|
Return the rank of the point data. |
447 |
|
|
*/ |
448 |
woo409 |
757 |
ESCRIPT_DLL_API |
449 |
jgs |
94 |
inline |
450 |
|
|
int |
451 |
|
|
getDataPointRank() const |
452 |
|
|
{ |
453 |
|
|
return m_data->getPointDataView().getRank(); |
454 |
|
|
} |
455 |
|
|
|
456 |
|
|
/** |
457 |
|
|
\brief |
458 |
jgs |
102 |
Return the number of samples. |
459 |
jgs |
94 |
*/ |
460 |
woo409 |
757 |
ESCRIPT_DLL_API |
461 |
jgs |
94 |
inline |
462 |
|
|
int |
463 |
jgs |
102 |
getNumSamples() const |
464 |
jgs |
94 |
{ |
465 |
jgs |
102 |
return m_data->getNumSamples(); |
466 |
jgs |
94 |
} |
467 |
|
|
|
468 |
|
|
/** |
469 |
|
|
\brief |
470 |
jgs |
102 |
Return the number of data points per sample. |
471 |
jgs |
94 |
*/ |
472 |
woo409 |
757 |
ESCRIPT_DLL_API |
473 |
jgs |
102 |
inline |
474 |
jgs |
94 |
int |
475 |
jgs |
102 |
getNumDataPointsPerSample() const |
476 |
|
|
{ |
477 |
|
|
return m_data->getNumDPPSample(); |
478 |
|
|
} |
479 |
jgs |
94 |
|
480 |
|
|
/** |
481 |
|
|
\brief |
482 |
|
|
Return the sample data for the given sample no. This is not the |
483 |
|
|
preferred interface but is provided for use by C code. |
484 |
|
|
\param sampleNo - Input - the given sample no. |
485 |
|
|
*/ |
486 |
woo409 |
757 |
ESCRIPT_DLL_API |
487 |
jgs |
102 |
inline |
488 |
jgs |
94 |
DataAbstract::ValueType::value_type* |
489 |
jgs |
102 |
getSampleData(DataAbstract::ValueType::size_type sampleNo) |
490 |
|
|
{ |
491 |
|
|
return m_data->getSampleData(sampleNo); |
492 |
|
|
} |
493 |
jgs |
94 |
|
494 |
|
|
/** |
495 |
|
|
\brief |
496 |
|
|
Return the sample data for the given tag. If an attempt is made to |
497 |
|
|
access data that isn't tagged an exception will be thrown. |
498 |
|
|
\param tag - Input - the tag key. |
499 |
|
|
*/ |
500 |
woo409 |
757 |
ESCRIPT_DLL_API |
501 |
jgs |
102 |
inline |
502 |
jgs |
94 |
DataAbstract::ValueType::value_type* |
503 |
jgs |
102 |
getSampleDataByTag(int tag) |
504 |
|
|
{ |
505 |
|
|
return m_data->getSampleDataByTag(tag); |
506 |
|
|
} |
507 |
jgs |
94 |
|
508 |
|
|
/** |
509 |
|
|
\brief |
510 |
jgs |
110 |
Assign the given value to the data-points referenced by the given |
511 |
|
|
reference number. |
512 |
|
|
|
513 |
|
|
The value supplied is a python numarray object. The data from this numarray |
514 |
|
|
is unpacked into a DataArray, and this is used to set the corresponding |
515 |
|
|
data-points in the underlying Data object. |
516 |
|
|
|
517 |
|
|
If the underlying Data object cannot be accessed via reference numbers, an |
518 |
|
|
exception will be thrown. |
519 |
|
|
|
520 |
|
|
\param ref - Input - reference number. |
521 |
|
|
\param value - Input - value to assign to data-points associated with |
522 |
|
|
the given reference number. |
523 |
|
|
*/ |
524 |
woo409 |
757 |
ESCRIPT_DLL_API |
525 |
jgs |
110 |
void |
526 |
|
|
setRefValue(int ref, |
527 |
|
|
const boost::python::numeric::array& value); |
528 |
|
|
|
529 |
|
|
/** |
530 |
|
|
\brief |
531 |
|
|
Return the values associated with the data-points referenced by the given |
532 |
|
|
reference number. |
533 |
|
|
|
534 |
|
|
The value supplied is a python numarray object. The data from the corresponding |
535 |
|
|
data-points in this Data object are packed into the given numarray object. |
536 |
|
|
|
537 |
|
|
If the underlying Data object cannot be accessed via reference numbers, an |
538 |
|
|
exception will be thrown. |
539 |
|
|
|
540 |
|
|
\param ref - Input - reference number. |
541 |
|
|
\param value - Output - object to receive values from data-points |
542 |
|
|
associated with the given reference number. |
543 |
|
|
*/ |
544 |
woo409 |
757 |
ESCRIPT_DLL_API |
545 |
jgs |
110 |
void |
546 |
|
|
getRefValue(int ref, |
547 |
|
|
boost::python::numeric::array& value); |
548 |
|
|
|
549 |
|
|
/** |
550 |
|
|
\brief |
551 |
jgs |
94 |
Return a view into the data for the data point specified. |
552 |
|
|
NOTE: Construction of the DataArrayView is a relatively expensive |
553 |
|
|
operation. |
554 |
|
|
\param sampleNo - Input - |
555 |
|
|
\param dataPointNo - Input - |
556 |
|
|
*/ |
557 |
woo409 |
757 |
ESCRIPT_DLL_API |
558 |
jgs |
94 |
inline |
559 |
|
|
DataArrayView |
560 |
|
|
getDataPoint(int sampleNo, |
561 |
|
|
int dataPointNo) |
562 |
|
|
{ |
563 |
bcumming |
790 |
return m_data->getDataPoint(sampleNo,dataPointNo); |
564 |
jgs |
94 |
} |
565 |
|
|
|
566 |
|
|
/** |
567 |
|
|
\brief |
568 |
|
|
Return a reference to the data point shape. |
569 |
|
|
*/ |
570 |
woo409 |
757 |
ESCRIPT_DLL_API |
571 |
jgs |
94 |
const DataArrayView::ShapeType& |
572 |
|
|
getDataPointShape() const; |
573 |
|
|
|
574 |
|
|
/** |
575 |
|
|
\brief |
576 |
jgs |
102 |
Return the data point shape as a tuple of integers. |
577 |
jgs |
94 |
*/ |
578 |
woo409 |
757 |
ESCRIPT_DLL_API |
579 |
jgs |
121 |
const boost::python::tuple |
580 |
jgs |
94 |
getShapeTuple() const; |
581 |
|
|
|
582 |
|
|
/** |
583 |
|
|
\brief |
584 |
|
|
Return the size of the data point. It is the product of the |
585 |
|
|
data point shape dimensions. |
586 |
|
|
*/ |
587 |
woo409 |
757 |
ESCRIPT_DLL_API |
588 |
jgs |
94 |
int |
589 |
|
|
getDataPointSize() const; |
590 |
|
|
|
591 |
|
|
/** |
592 |
|
|
\brief |
593 |
jgs |
102 |
Return the number of doubles stored for this Data. |
594 |
jgs |
94 |
*/ |
595 |
woo409 |
757 |
ESCRIPT_DLL_API |
596 |
jgs |
94 |
DataArrayView::ValueType::size_type |
597 |
|
|
getLength() const; |
598 |
|
|
|
599 |
|
|
/** |
600 |
|
|
\brief |
601 |
jgs |
102 |
Assign the given value to the tag. Implicitly converts this |
602 |
|
|
object to type DataTagged. Throws an exception if this object |
603 |
|
|
cannot be converted to a DataTagged object. |
604 |
|
|
\param tagKey - Input - Integer key. |
605 |
|
|
\param value - Input - Value to associate with given key. |
606 |
jgs |
544 |
==>* |
607 |
jgs |
94 |
*/ |
608 |
woo409 |
757 |
ESCRIPT_DLL_API |
609 |
jgs |
102 |
void |
610 |
|
|
setTaggedValue(int tagKey, |
611 |
|
|
const boost::python::object& value); |
612 |
|
|
|
613 |
|
|
/** |
614 |
|
|
\brief |
615 |
|
|
Assign the given value to the tag. Implicitly converts this |
616 |
|
|
object to type DataTagged. Throws an exception if this object |
617 |
|
|
cannot be converted to a DataTagged object. |
618 |
|
|
\param tagKey - Input - Integer key. |
619 |
|
|
\param value - Input - Value to associate with given key. |
620 |
jgs |
544 |
==>* |
621 |
jgs |
102 |
*/ |
622 |
woo409 |
757 |
ESCRIPT_DLL_API |
623 |
jgs |
102 |
void |
624 |
jgs |
121 |
setTaggedValueFromCPP(int tagKey, |
625 |
|
|
const DataArrayView& value); |
626 |
jgs |
102 |
|
627 |
|
|
/** |
628 |
|
|
\brief |
629 |
|
|
Copy other Data object into this Data object where mask is positive. |
630 |
|
|
*/ |
631 |
woo409 |
757 |
ESCRIPT_DLL_API |
632 |
jgs |
102 |
void |
633 |
|
|
copyWithMask(const Data& other, |
634 |
|
|
const Data& mask); |
635 |
|
|
|
636 |
|
|
/** |
637 |
|
|
Data object operation methods and operators. |
638 |
|
|
*/ |
639 |
|
|
|
640 |
|
|
/** |
641 |
|
|
\brief |
642 |
|
|
Interpolates this onto the given functionspace and returns |
643 |
|
|
the result as a Data object. |
644 |
jgs |
123 |
* |
645 |
jgs |
102 |
*/ |
646 |
woo409 |
757 |
ESCRIPT_DLL_API |
647 |
jgs |
94 |
Data |
648 |
|
|
interpolate(const FunctionSpace& functionspace) const; |
649 |
|
|
|
650 |
|
|
/** |
651 |
|
|
\brief |
652 |
|
|
Calculates the gradient of the data at the data points of functionspace. |
653 |
|
|
If functionspace is not present the function space of Function(getDomain()) is used. |
654 |
jgs |
123 |
* |
655 |
jgs |
94 |
*/ |
656 |
woo409 |
757 |
ESCRIPT_DLL_API |
657 |
jgs |
94 |
Data |
658 |
|
|
gradOn(const FunctionSpace& functionspace) const; |
659 |
|
|
|
660 |
woo409 |
757 |
ESCRIPT_DLL_API |
661 |
jgs |
94 |
Data |
662 |
|
|
grad() const; |
663 |
|
|
|
664 |
|
|
/** |
665 |
|
|
\brief |
666 |
|
|
Calculate the integral over the function space domain. |
667 |
jgs |
123 |
* |
668 |
jgs |
94 |
*/ |
669 |
woo409 |
757 |
ESCRIPT_DLL_API |
670 |
jgs |
94 |
boost::python::numeric::array |
671 |
|
|
integrate() const; |
672 |
|
|
|
673 |
|
|
/** |
674 |
|
|
\brief |
675 |
gross |
854 |
Returns 1./ Data object |
676 |
|
|
* |
677 |
|
|
*/ |
678 |
|
|
ESCRIPT_DLL_API |
679 |
|
|
Data |
680 |
|
|
oneOver() const; |
681 |
|
|
/** |
682 |
|
|
\brief |
683 |
jgs |
94 |
Return a Data with a 1 for +ive values and a 0 for 0 or -ive values. |
684 |
jgs |
123 |
* |
685 |
jgs |
94 |
*/ |
686 |
woo409 |
757 |
ESCRIPT_DLL_API |
687 |
jgs |
94 |
Data |
688 |
gross |
698 |
wherePositive() const; |
689 |
jgs |
94 |
|
690 |
|
|
/** |
691 |
|
|
\brief |
692 |
jgs |
102 |
Return a Data with a 1 for -ive values and a 0 for +ive or 0 values. |
693 |
jgs |
123 |
* |
694 |
jgs |
94 |
*/ |
695 |
woo409 |
757 |
ESCRIPT_DLL_API |
696 |
jgs |
94 |
Data |
697 |
gross |
698 |
whereNegative() const; |
698 |
jgs |
102 |
|
699 |
|
|
/** |
700 |
|
|
\brief |
701 |
|
|
Return a Data with a 1 for +ive or 0 values and a 0 for -ive values. |
702 |
jgs |
123 |
* |
703 |
jgs |
102 |
*/ |
704 |
woo409 |
757 |
ESCRIPT_DLL_API |
705 |
jgs |
102 |
Data |
706 |
gross |
698 |
whereNonNegative() const; |
707 |
jgs |
94 |
|
708 |
|
|
/** |
709 |
|
|
\brief |
710 |
jgs |
102 |
Return a Data with a 1 for -ive or 0 values and a 0 for +ive values. |
711 |
jgs |
123 |
* |
712 |
jgs |
94 |
*/ |
713 |
woo409 |
757 |
ESCRIPT_DLL_API |
714 |
jgs |
94 |
Data |
715 |
gross |
698 |
whereNonPositive() const; |
716 |
jgs |
94 |
|
717 |
|
|
/** |
718 |
|
|
\brief |
719 |
jgs |
102 |
Return a Data with a 1 for 0 values and a 0 for +ive or -ive values. |
720 |
jgs |
123 |
* |
721 |
jgs |
94 |
*/ |
722 |
woo409 |
757 |
ESCRIPT_DLL_API |
723 |
jgs |
94 |
Data |
724 |
jgs |
571 |
whereZero(double tol=0.0) const; |
725 |
jgs |
94 |
|
726 |
|
|
/** |
727 |
|
|
\brief |
728 |
jgs |
102 |
Return a Data with a 0 for 0 values and a 1 for +ive or -ive values. |
729 |
jgs |
123 |
* |
730 |
jgs |
94 |
*/ |
731 |
woo409 |
757 |
ESCRIPT_DLL_API |
732 |
jgs |
94 |
Data |
733 |
jgs |
571 |
whereNonZero(double tol=0.0) const; |
734 |
jgs |
102 |
|
735 |
|
|
/** |
736 |
|
|
\brief |
737 |
|
|
Return the maximum absolute value of this Data object. |
738 |
jgs |
123 |
* |
739 |
jgs |
94 |
*/ |
740 |
woo409 |
757 |
ESCRIPT_DLL_API |
741 |
jgs |
102 |
double |
742 |
|
|
Lsup() const; |
743 |
jgs |
94 |
|
744 |
|
|
/** |
745 |
|
|
\brief |
746 |
jgs |
117 |
Return the minimum absolute value of this Data object. |
747 |
jgs |
123 |
* |
748 |
jgs |
117 |
*/ |
749 |
woo409 |
757 |
ESCRIPT_DLL_API |
750 |
jgs |
117 |
double |
751 |
|
|
Linf() const; |
752 |
|
|
|
753 |
|
|
/** |
754 |
|
|
\brief |
755 |
jgs |
102 |
Return the maximum value of this Data object. |
756 |
jgs |
123 |
* |
757 |
jgs |
94 |
*/ |
758 |
woo409 |
757 |
ESCRIPT_DLL_API |
759 |
jgs |
102 |
double |
760 |
|
|
sup() const; |
761 |
jgs |
94 |
|
762 |
|
|
/** |
763 |
|
|
\brief |
764 |
jgs |
102 |
Return the minimum value of this Data object. |
765 |
jgs |
123 |
* |
766 |
jgs |
94 |
*/ |
767 |
woo409 |
757 |
ESCRIPT_DLL_API |
768 |
jgs |
94 |
double |
769 |
jgs |
102 |
inf() const; |
770 |
jgs |
94 |
|
771 |
|
|
/** |
772 |
|
|
\brief |
773 |
jgs |
102 |
Return the absolute value of each data point of this Data object. |
774 |
jgs |
123 |
* |
775 |
jgs |
94 |
*/ |
776 |
woo409 |
757 |
ESCRIPT_DLL_API |
777 |
jgs |
102 |
Data |
778 |
|
|
abs() const; |
779 |
jgs |
94 |
|
780 |
|
|
/** |
781 |
|
|
\brief |
782 |
jgs |
102 |
Return the maximum value of each data point of this Data object. |
783 |
jgs |
123 |
* |
784 |
jgs |
94 |
*/ |
785 |
woo409 |
757 |
ESCRIPT_DLL_API |
786 |
jgs |
102 |
Data |
787 |
|
|
maxval() const; |
788 |
jgs |
94 |
|
789 |
|
|
/** |
790 |
|
|
\brief |
791 |
jgs |
102 |
Return the minimum value of each data point of this Data object. |
792 |
jgs |
123 |
* |
793 |
jgs |
94 |
*/ |
794 |
woo409 |
757 |
ESCRIPT_DLL_API |
795 |
jgs |
94 |
Data |
796 |
jgs |
102 |
minval() const; |
797 |
jgs |
94 |
|
798 |
|
|
/** |
799 |
|
|
\brief |
800 |
jgs |
121 |
Return the (sample number, data-point number) of the data point with |
801 |
|
|
the minimum value in this Data object. |
802 |
|
|
*/ |
803 |
woo409 |
757 |
ESCRIPT_DLL_API |
804 |
jgs |
121 |
const boost::python::tuple |
805 |
|
|
mindp() const; |
806 |
|
|
|
807 |
woo409 |
757 |
ESCRIPT_DLL_API |
808 |
jgs |
148 |
void |
809 |
bcumming |
782 |
calc_mindp(int& ProcNo, |
810 |
|
|
int& SampleNo, |
811 |
|
|
int& DataPointNo) const; |
812 |
jgs |
121 |
/** |
813 |
|
|
\brief |
814 |
jgs |
102 |
Return the sign of each data point of this Data object. |
815 |
|
|
-1 for negative values, zero for zero values, 1 for positive values. |
816 |
jgs |
123 |
* |
817 |
jgs |
94 |
*/ |
818 |
woo409 |
757 |
ESCRIPT_DLL_API |
819 |
jgs |
102 |
Data |
820 |
|
|
sign() const; |
821 |
jgs |
94 |
|
822 |
|
|
/** |
823 |
jgs |
123 |
\brief |
824 |
ksteube |
775 |
Return the symmetric part of a matrix which is half the matrix plus its transpose. |
825 |
|
|
* |
826 |
|
|
*/ |
827 |
|
|
ESCRIPT_DLL_API |
828 |
|
|
Data |
829 |
|
|
symmetric() const; |
830 |
|
|
|
831 |
|
|
/** |
832 |
|
|
\brief |
833 |
|
|
Return the nonsymmetric part of a matrix which is half the matrix minus its transpose. |
834 |
|
|
* |
835 |
|
|
*/ |
836 |
|
|
ESCRIPT_DLL_API |
837 |
|
|
Data |
838 |
|
|
nonsymmetric() const; |
839 |
|
|
|
840 |
|
|
/** |
841 |
|
|
\brief |
842 |
|
|
Return the trace of a matrix |
843 |
|
|
* |
844 |
|
|
*/ |
845 |
|
|
ESCRIPT_DLL_API |
846 |
|
|
Data |
847 |
gross |
800 |
trace(int axis_offset) const; |
848 |
ksteube |
775 |
|
849 |
|
|
/** |
850 |
|
|
\brief |
851 |
|
|
Transpose each data point of this Data object around the given axis. |
852 |
|
|
* |
853 |
|
|
*/ |
854 |
|
|
ESCRIPT_DLL_API |
855 |
|
|
Data |
856 |
|
|
transpose(int axis_offset) const; |
857 |
|
|
|
858 |
|
|
/** |
859 |
|
|
\brief |
860 |
gross |
576 |
Return the eigenvalues of the symmetric part at each data point of this Data object in increasing values. |
861 |
|
|
Currently this function is restricted to rank 2, square shape, and dimension 3. |
862 |
|
|
* |
863 |
|
|
*/ |
864 |
woo409 |
757 |
ESCRIPT_DLL_API |
865 |
gross |
576 |
Data |
866 |
|
|
eigenvalues() const; |
867 |
|
|
|
868 |
|
|
/** |
869 |
|
|
\brief |
870 |
|
|
Return the eigenvalues and corresponding eigenvcetors of the symmetric part at each data point of this Data object. |
871 |
|
|
the eigenvalues are ordered in increasing size where eigenvalues with relative difference less than |
872 |
|
|
tol are treated as equal. The eigenvectors are orthogonal, normalized and the sclaed such that the |
873 |
|
|
first non-zero entry is positive. |
874 |
|
|
Currently this function is restricted to rank 2, square shape, and dimension 3 |
875 |
|
|
* |
876 |
|
|
*/ |
877 |
woo409 |
757 |
ESCRIPT_DLL_API |
878 |
gross |
576 |
const boost::python::tuple |
879 |
|
|
eigenvalues_and_eigenvectors(const double tol=1.e-12) const; |
880 |
|
|
|
881 |
|
|
/** |
882 |
|
|
\brief |
883 |
gross |
804 |
swaps the components axis0 and axis1 |
884 |
jgs |
123 |
* |
885 |
jgs |
102 |
*/ |
886 |
woo409 |
757 |
ESCRIPT_DLL_API |
887 |
jgs |
102 |
Data |
888 |
gross |
804 |
swapaxes(const int axis0, const int axis1) const; |
889 |
jgs |
102 |
|
890 |
|
|
/** |
891 |
jgs |
123 |
\brief |
892 |
ksteube |
876 |
Return the error function erf of each data point of this Data object. |
893 |
|
|
* |
894 |
|
|
*/ |
895 |
|
|
ESCRIPT_DLL_API |
896 |
|
|
Data |
897 |
|
|
erf() const; |
898 |
|
|
|
899 |
|
|
/** |
900 |
|
|
\brief |
901 |
jgs |
123 |
Return the sin of each data point of this Data object. |
902 |
|
|
* |
903 |
jgs |
102 |
*/ |
904 |
woo409 |
757 |
ESCRIPT_DLL_API |
905 |
jgs |
102 |
Data |
906 |
jgs |
123 |
sin() const; |
907 |
|
|
|
908 |
|
|
/** |
909 |
|
|
\brief |
910 |
|
|
Return the cos of each data point of this Data object. |
911 |
|
|
* |
912 |
|
|
*/ |
913 |
woo409 |
757 |
ESCRIPT_DLL_API |
914 |
jgs |
123 |
Data |
915 |
|
|
cos() const; |
916 |
|
|
|
917 |
|
|
/** |
918 |
|
|
\brief |
919 |
|
|
Return the tan of each data point of this Data object. |
920 |
|
|
* |
921 |
|
|
*/ |
922 |
woo409 |
757 |
ESCRIPT_DLL_API |
923 |
jgs |
123 |
Data |
924 |
|
|
tan() const; |
925 |
|
|
|
926 |
|
|
/** |
927 |
|
|
\brief |
928 |
jgs |
150 |
Return the asin of each data point of this Data object. |
929 |
|
|
* |
930 |
|
|
*/ |
931 |
woo409 |
757 |
ESCRIPT_DLL_API |
932 |
jgs |
150 |
Data |
933 |
|
|
asin() const; |
934 |
|
|
|
935 |
|
|
/** |
936 |
|
|
\brief |
937 |
|
|
Return the acos of each data point of this Data object. |
938 |
|
|
* |
939 |
|
|
*/ |
940 |
woo409 |
757 |
ESCRIPT_DLL_API |
941 |
jgs |
150 |
Data |
942 |
|
|
acos() const; |
943 |
|
|
|
944 |
|
|
/** |
945 |
|
|
\brief |
946 |
|
|
Return the atan of each data point of this Data object. |
947 |
|
|
* |
948 |
|
|
*/ |
949 |
woo409 |
757 |
ESCRIPT_DLL_API |
950 |
jgs |
150 |
Data |
951 |
|
|
atan() const; |
952 |
|
|
|
953 |
|
|
/** |
954 |
|
|
\brief |
955 |
|
|
Return the sinh of each data point of this Data object. |
956 |
|
|
* |
957 |
|
|
*/ |
958 |
woo409 |
757 |
ESCRIPT_DLL_API |
959 |
jgs |
150 |
Data |
960 |
|
|
sinh() const; |
961 |
|
|
|
962 |
|
|
/** |
963 |
|
|
\brief |
964 |
|
|
Return the cosh of each data point of this Data object. |
965 |
|
|
* |
966 |
|
|
*/ |
967 |
woo409 |
757 |
ESCRIPT_DLL_API |
968 |
jgs |
150 |
Data |
969 |
|
|
cosh() const; |
970 |
|
|
|
971 |
|
|
/** |
972 |
|
|
\brief |
973 |
|
|
Return the tanh of each data point of this Data object. |
974 |
|
|
* |
975 |
|
|
*/ |
976 |
woo409 |
757 |
ESCRIPT_DLL_API |
977 |
jgs |
150 |
Data |
978 |
|
|
tanh() const; |
979 |
|
|
|
980 |
|
|
/** |
981 |
|
|
\brief |
982 |
|
|
Return the asinh of each data point of this Data object. |
983 |
|
|
* |
984 |
|
|
*/ |
985 |
woo409 |
757 |
ESCRIPT_DLL_API |
986 |
jgs |
150 |
Data |
987 |
|
|
asinh() const; |
988 |
|
|
|
989 |
|
|
/** |
990 |
|
|
\brief |
991 |
|
|
Return the acosh of each data point of this Data object. |
992 |
|
|
* |
993 |
|
|
*/ |
994 |
woo409 |
757 |
ESCRIPT_DLL_API |
995 |
jgs |
150 |
Data |
996 |
|
|
acosh() const; |
997 |
|
|
|
998 |
|
|
/** |
999 |
|
|
\brief |
1000 |
|
|
Return the atanh of each data point of this Data object. |
1001 |
|
|
* |
1002 |
|
|
*/ |
1003 |
woo409 |
757 |
ESCRIPT_DLL_API |
1004 |
jgs |
150 |
Data |
1005 |
|
|
atanh() const; |
1006 |
|
|
|
1007 |
|
|
/** |
1008 |
|
|
\brief |
1009 |
jgs |
123 |
Return the log to base 10 of each data point of this Data object. |
1010 |
|
|
* |
1011 |
|
|
*/ |
1012 |
woo409 |
757 |
ESCRIPT_DLL_API |
1013 |
jgs |
123 |
Data |
1014 |
gross |
286 |
log10() const; |
1015 |
jgs |
123 |
|
1016 |
|
|
/** |
1017 |
|
|
\brief |
1018 |
|
|
Return the natural log of each data point of this Data object. |
1019 |
|
|
* |
1020 |
|
|
*/ |
1021 |
woo409 |
757 |
ESCRIPT_DLL_API |
1022 |
jgs |
123 |
Data |
1023 |
gross |
286 |
log() const; |
1024 |
jgs |
123 |
|
1025 |
|
|
/** |
1026 |
|
|
\brief |
1027 |
|
|
Return the exponential function of each data point of this Data object. |
1028 |
|
|
* |
1029 |
|
|
*/ |
1030 |
woo409 |
757 |
ESCRIPT_DLL_API |
1031 |
jgs |
123 |
Data |
1032 |
jgs |
102 |
exp() const; |
1033 |
|
|
|
1034 |
|
|
/** |
1035 |
jgs |
123 |
\brief |
1036 |
|
|
Return the square root of each data point of this Data object. |
1037 |
|
|
* |
1038 |
jgs |
102 |
*/ |
1039 |
woo409 |
757 |
ESCRIPT_DLL_API |
1040 |
jgs |
102 |
Data |
1041 |
|
|
sqrt() const; |
1042 |
|
|
|
1043 |
|
|
/** |
1044 |
jgs |
123 |
\brief |
1045 |
|
|
Return the negation of each data point of this Data object. |
1046 |
|
|
* |
1047 |
jgs |
121 |
*/ |
1048 |
woo409 |
757 |
ESCRIPT_DLL_API |
1049 |
jgs |
121 |
Data |
1050 |
|
|
neg() const; |
1051 |
|
|
|
1052 |
|
|
/** |
1053 |
jgs |
123 |
\brief |
1054 |
|
|
Return the identity of each data point of this Data object. |
1055 |
|
|
Simply returns this object unmodified. |
1056 |
|
|
* |
1057 |
jgs |
121 |
*/ |
1058 |
woo409 |
757 |
ESCRIPT_DLL_API |
1059 |
jgs |
121 |
Data |
1060 |
|
|
pos() const; |
1061 |
|
|
|
1062 |
|
|
/** |
1063 |
jgs |
94 |
\brief |
1064 |
jgs |
102 |
Return the given power of each data point of this Data object. |
1065 |
jgs |
121 |
|
1066 |
|
|
\param right Input - the power to raise the object to. |
1067 |
jgs |
123 |
* |
1068 |
jgs |
102 |
*/ |
1069 |
woo409 |
757 |
ESCRIPT_DLL_API |
1070 |
jgs |
102 |
Data |
1071 |
|
|
powD(const Data& right) const; |
1072 |
|
|
|
1073 |
jgs |
121 |
/** |
1074 |
jgs |
123 |
\brief |
1075 |
|
|
Return the given power of each data point of this boost python object. |
1076 |
|
|
|
1077 |
|
|
\param right Input - the power to raise the object to. |
1078 |
|
|
* |
1079 |
jgs |
121 |
*/ |
1080 |
woo409 |
757 |
ESCRIPT_DLL_API |
1081 |
jgs |
102 |
Data |
1082 |
|
|
powO(const boost::python::object& right) const; |
1083 |
|
|
|
1084 |
|
|
/** |
1085 |
jgs |
123 |
\brief |
1086 |
gross |
699 |
Return the given power of each data point of this boost python object. |
1087 |
|
|
|
1088 |
|
|
\param left Input - the bases |
1089 |
|
|
* |
1090 |
|
|
*/ |
1091 |
|
|
|
1092 |
woo409 |
757 |
ESCRIPT_DLL_API |
1093 |
gross |
699 |
Data |
1094 |
|
|
rpowO(const boost::python::object& left) const; |
1095 |
|
|
|
1096 |
|
|
/** |
1097 |
|
|
\brief |
1098 |
jgs |
123 |
writes the object to a file in the DX file format |
1099 |
jgs |
104 |
*/ |
1100 |
woo409 |
757 |
ESCRIPT_DLL_API |
1101 |
jgs |
104 |
void |
1102 |
|
|
saveDX(std::string fileName) const; |
1103 |
|
|
|
1104 |
|
|
/** |
1105 |
jgs |
123 |
\brief |
1106 |
|
|
writes the object to a file in the VTK file format |
1107 |
jgs |
110 |
*/ |
1108 |
woo409 |
757 |
ESCRIPT_DLL_API |
1109 |
jgs |
110 |
void |
1110 |
|
|
saveVTK(std::string fileName) const; |
1111 |
|
|
|
1112 |
|
|
/** |
1113 |
jgs |
102 |
\brief |
1114 |
|
|
Overloaded operator += |
1115 |
|
|
\param right - Input - The right hand side. |
1116 |
jgs |
123 |
* |
1117 |
jgs |
102 |
*/ |
1118 |
woo409 |
757 |
ESCRIPT_DLL_API |
1119 |
jgs |
102 |
Data& operator+=(const Data& right); |
1120 |
woo409 |
757 |
ESCRIPT_DLL_API |
1121 |
jgs |
102 |
Data& operator+=(const boost::python::object& right); |
1122 |
|
|
|
1123 |
|
|
/** |
1124 |
|
|
\brief |
1125 |
|
|
Overloaded operator -= |
1126 |
|
|
\param right - Input - The right hand side. |
1127 |
jgs |
123 |
* |
1128 |
jgs |
102 |
*/ |
1129 |
woo409 |
757 |
ESCRIPT_DLL_API |
1130 |
jgs |
102 |
Data& operator-=(const Data& right); |
1131 |
woo409 |
757 |
ESCRIPT_DLL_API |
1132 |
jgs |
102 |
Data& operator-=(const boost::python::object& right); |
1133 |
|
|
|
1134 |
|
|
/** |
1135 |
|
|
\brief |
1136 |
|
|
Overloaded operator *= |
1137 |
|
|
\param right - Input - The right hand side. |
1138 |
jgs |
123 |
* |
1139 |
jgs |
102 |
*/ |
1140 |
woo409 |
757 |
ESCRIPT_DLL_API |
1141 |
jgs |
102 |
Data& operator*=(const Data& right); |
1142 |
woo409 |
757 |
ESCRIPT_DLL_API |
1143 |
jgs |
102 |
Data& operator*=(const boost::python::object& right); |
1144 |
|
|
|
1145 |
|
|
/** |
1146 |
|
|
\brief |
1147 |
|
|
Overloaded operator /= |
1148 |
|
|
\param right - Input - The right hand side. |
1149 |
jgs |
123 |
* |
1150 |
jgs |
102 |
*/ |
1151 |
woo409 |
757 |
ESCRIPT_DLL_API |
1152 |
jgs |
102 |
Data& operator/=(const Data& right); |
1153 |
woo409 |
757 |
ESCRIPT_DLL_API |
1154 |
jgs |
102 |
Data& operator/=(const boost::python::object& right); |
1155 |
|
|
|
1156 |
|
|
/** |
1157 |
|
|
\brief |
1158 |
jgs |
94 |
Returns true if this can be interpolated to functionspace. |
1159 |
|
|
*/ |
1160 |
woo409 |
757 |
ESCRIPT_DLL_API |
1161 |
jgs |
94 |
bool |
1162 |
|
|
probeInterpolation(const FunctionSpace& functionspace) const; |
1163 |
|
|
|
1164 |
|
|
/** |
1165 |
jgs |
102 |
Data object slicing methods. |
1166 |
|
|
*/ |
1167 |
|
|
|
1168 |
|
|
/** |
1169 |
jgs |
94 |
\brief |
1170 |
jgs |
102 |
Returns a slice from this Data object. |
1171 |
|
|
|
1172 |
|
|
/description |
1173 |
|
|
Implements the [] get operator in python. |
1174 |
|
|
Calls getSlice. |
1175 |
|
|
|
1176 |
|
|
\param key - Input - python slice tuple specifying |
1177 |
|
|
slice to return. |
1178 |
jgs |
94 |
*/ |
1179 |
woo409 |
757 |
ESCRIPT_DLL_API |
1180 |
jgs |
102 |
Data |
1181 |
|
|
getItem(const boost::python::object& key) const; |
1182 |
|
|
|
1183 |
|
|
/** |
1184 |
|
|
\brief |
1185 |
|
|
Copies slice from value into this Data object. |
1186 |
|
|
|
1187 |
|
|
Implements the [] set operator in python. |
1188 |
|
|
Calls setSlice. |
1189 |
|
|
|
1190 |
|
|
\param key - Input - python slice tuple specifying |
1191 |
|
|
slice to copy from value. |
1192 |
|
|
\param value - Input - Data object to copy from. |
1193 |
|
|
*/ |
1194 |
woo409 |
757 |
ESCRIPT_DLL_API |
1195 |
jgs |
94 |
void |
1196 |
jgs |
102 |
setItemD(const boost::python::object& key, |
1197 |
|
|
const Data& value); |
1198 |
jgs |
94 |
|
1199 |
woo409 |
757 |
ESCRIPT_DLL_API |
1200 |
jgs |
102 |
void |
1201 |
|
|
setItemO(const boost::python::object& key, |
1202 |
|
|
const boost::python::object& value); |
1203 |
|
|
|
1204 |
|
|
// These following public methods should be treated as private. |
1205 |
|
|
|
1206 |
jgs |
94 |
/** |
1207 |
|
|
\brief |
1208 |
jgs |
102 |
Perform the given unary operation on every element of every data point in |
1209 |
|
|
this Data object. |
1210 |
jgs |
94 |
*/ |
1211 |
jgs |
102 |
template <class UnaryFunction> |
1212 |
woo409 |
757 |
ESCRIPT_DLL_API |
1213 |
jgs |
102 |
inline |
1214 |
jgs |
94 |
void |
1215 |
jgs |
102 |
unaryOp(UnaryFunction operation); |
1216 |
|
|
|
1217 |
|
|
/** |
1218 |
|
|
\brief |
1219 |
|
|
Return a Data object containing the specified slice of |
1220 |
|
|
this Data object. |
1221 |
|
|
\param region - Input - Region to copy. |
1222 |
jgs |
123 |
* |
1223 |
jgs |
94 |
*/ |
1224 |
woo409 |
757 |
ESCRIPT_DLL_API |
1225 |
jgs |
102 |
Data |
1226 |
|
|
getSlice(const DataArrayView::RegionType& region) const; |
1227 |
jgs |
94 |
|
1228 |
jgs |
102 |
/** |
1229 |
|
|
\brief |
1230 |
|
|
Copy the specified slice from the given value into this |
1231 |
|
|
Data object. |
1232 |
|
|
\param value - Input - Data to copy from. |
1233 |
|
|
\param region - Input - Region to copy. |
1234 |
jgs |
123 |
* |
1235 |
jgs |
102 |
*/ |
1236 |
woo409 |
757 |
ESCRIPT_DLL_API |
1237 |
jgs |
102 |
void |
1238 |
|
|
setSlice(const Data& value, |
1239 |
|
|
const DataArrayView::RegionType& region); |
1240 |
|
|
|
1241 |
jgs |
119 |
/** |
1242 |
|
|
\brief |
1243 |
|
|
Archive the current Data object to the given file. |
1244 |
|
|
\param fileName - Input - file to archive to. |
1245 |
|
|
*/ |
1246 |
woo409 |
757 |
ESCRIPT_DLL_API |
1247 |
jgs |
119 |
void |
1248 |
|
|
archiveData(const std::string fileName); |
1249 |
|
|
|
1250 |
|
|
/** |
1251 |
|
|
\brief |
1252 |
|
|
Extract the Data object archived in the given file, overwriting |
1253 |
|
|
the current Data object. |
1254 |
|
|
Note - the current object must be of type DataEmpty. |
1255 |
|
|
\param fileName - Input - file to extract from. |
1256 |
jgs |
121 |
\param fspace - Input - a suitable FunctionSpace descibing the data. |
1257 |
jgs |
119 |
*/ |
1258 |
woo409 |
757 |
ESCRIPT_DLL_API |
1259 |
jgs |
119 |
void |
1260 |
|
|
extractData(const std::string fileName, |
1261 |
|
|
const FunctionSpace& fspace); |
1262 |
|
|
|
1263 |
bcumming |
751 |
|
1264 |
|
|
/** |
1265 |
|
|
\brief |
1266 |
|
|
print the data values to stdout. Used for debugging |
1267 |
|
|
*/ |
1268 |
bcumming |
782 |
ESCRIPT_DLL_API |
1269 |
|
|
void |
1270 |
|
|
print(void); |
1271 |
bcumming |
751 |
|
1272 |
bcumming |
782 |
/** |
1273 |
|
|
\brief |
1274 |
|
|
return the MPI rank number of the local data |
1275 |
|
|
MPI_COMM_WORLD is assumed and the result of MPI_Comm_size() |
1276 |
|
|
is returned |
1277 |
|
|
*/ |
1278 |
|
|
ESCRIPT_DLL_API |
1279 |
|
|
int |
1280 |
|
|
get_MPIRank(void) const; |
1281 |
|
|
|
1282 |
|
|
/** |
1283 |
|
|
\brief |
1284 |
|
|
return the MPI rank number of the local data |
1285 |
|
|
MPI_COMM_WORLD is assumed and the result of MPI_Comm_rank() |
1286 |
|
|
is returned |
1287 |
|
|
*/ |
1288 |
|
|
ESCRIPT_DLL_API |
1289 |
|
|
int |
1290 |
|
|
get_MPISize(void) const; |
1291 |
|
|
|
1292 |
|
|
/** |
1293 |
|
|
\brief |
1294 |
|
|
return the MPI rank number of the local data |
1295 |
|
|
MPI_COMM_WORLD is assumed and returned. |
1296 |
|
|
*/ |
1297 |
|
|
ESCRIPT_DLL_API |
1298 |
|
|
MPI_Comm |
1299 |
|
|
get_MPIComm(void) const; |
1300 |
ksteube |
813 |
|
1301 |
|
|
/** |
1302 |
|
|
\brief |
1303 |
|
|
return the object produced by the factory, which is a DataConstant or DataExpanded |
1304 |
|
|
*/ |
1305 |
|
|
ESCRIPT_DLL_API |
1306 |
|
|
DataAbstract* |
1307 |
|
|
borrowData(void) const; |
1308 |
|
|
|
1309 |
jgs |
102 |
protected: |
1310 |
|
|
|
1311 |
jgs |
94 |
private: |
1312 |
|
|
|
1313 |
|
|
/** |
1314 |
|
|
\brief |
1315 |
jgs |
102 |
Check *this and the right operand are compatible. Throws |
1316 |
|
|
an exception if they aren't. |
1317 |
|
|
\param right - Input - The right hand side. |
1318 |
|
|
*/ |
1319 |
|
|
inline |
1320 |
|
|
void |
1321 |
|
|
operandCheck(const Data& right) const |
1322 |
|
|
{ |
1323 |
|
|
return m_data->operandCheck(*(right.m_data.get())); |
1324 |
|
|
} |
1325 |
|
|
|
1326 |
|
|
/** |
1327 |
|
|
\brief |
1328 |
|
|
Perform the specified reduction algorithm on every element of every data point in |
1329 |
jgs |
113 |
this Data object according to the given function and return the single value result. |
1330 |
jgs |
102 |
*/ |
1331 |
jgs |
147 |
template <class BinaryFunction> |
1332 |
jgs |
102 |
inline |
1333 |
|
|
double |
1334 |
jgs |
147 |
algorithm(BinaryFunction operation, |
1335 |
|
|
double initial_value) const; |
1336 |
jgs |
102 |
|
1337 |
jgs |
113 |
/** |
1338 |
|
|
\brief |
1339 |
|
|
Reduce each data-point in this Data object using the given operation. Return a Data |
1340 |
|
|
object with the same number of data-points, but with each data-point containing only |
1341 |
|
|
one value - the result of the reduction operation on the corresponding data-point in |
1342 |
|
|
this Data object |
1343 |
|
|
*/ |
1344 |
jgs |
147 |
template <class BinaryFunction> |
1345 |
jgs |
106 |
inline |
1346 |
|
|
Data |
1347 |
jgs |
147 |
dp_algorithm(BinaryFunction operation, |
1348 |
|
|
double initial_value) const; |
1349 |
jgs |
106 |
|
1350 |
jgs |
102 |
/** |
1351 |
|
|
\brief |
1352 |
|
|
Perform the given binary operation on all of the data's elements. |
1353 |
|
|
The underlying type of the right hand side (right) determines the final |
1354 |
|
|
type of *this after the operation. For example if the right hand side |
1355 |
|
|
is expanded *this will be expanded if necessary. |
1356 |
|
|
RHS is a Data object. |
1357 |
|
|
*/ |
1358 |
|
|
template <class BinaryFunction> |
1359 |
|
|
inline |
1360 |
|
|
void |
1361 |
|
|
binaryOp(const Data& right, |
1362 |
|
|
BinaryFunction operation); |
1363 |
|
|
|
1364 |
|
|
/** |
1365 |
|
|
\brief |
1366 |
|
|
Convert the data type of the RHS to match this. |
1367 |
|
|
\param right - Input - data type to match. |
1368 |
|
|
*/ |
1369 |
|
|
void |
1370 |
|
|
typeMatchLeft(Data& right) const; |
1371 |
|
|
|
1372 |
|
|
/** |
1373 |
|
|
\brief |
1374 |
|
|
Convert the data type of this to match the RHS. |
1375 |
|
|
\param right - Input - data type to match. |
1376 |
|
|
*/ |
1377 |
|
|
void |
1378 |
|
|
typeMatchRight(const Data& right); |
1379 |
|
|
|
1380 |
|
|
/** |
1381 |
|
|
\brief |
1382 |
jgs |
94 |
Construct a Data object of the appropriate type. |
1383 |
|
|
*/ |
1384 |
|
|
template <class IValueType> |
1385 |
|
|
void |
1386 |
|
|
initialise(const IValueType& value, |
1387 |
|
|
const FunctionSpace& what, |
1388 |
|
|
bool expanded); |
1389 |
|
|
|
1390 |
|
|
// |
1391 |
gross |
783 |
// flag to protect the data object against any update |
1392 |
|
|
bool m_protected; |
1393 |
|
|
|
1394 |
|
|
// |
1395 |
jgs |
102 |
// pointer to the actual data object |
1396 |
jgs |
94 |
boost::shared_ptr<DataAbstract> m_data; |
1397 |
|
|
|
1398 |
jgs |
123 |
// |
1399 |
|
|
// pointer to the internal profiling data |
1400 |
|
|
struct profDataEntry *profData; |
1401 |
|
|
|
1402 |
jgs |
94 |
}; |
1403 |
|
|
|
1404 |
|
|
template <class IValueType> |
1405 |
|
|
void |
1406 |
|
|
Data::initialise(const IValueType& value, |
1407 |
|
|
const FunctionSpace& what, |
1408 |
|
|
bool expanded) |
1409 |
|
|
{ |
1410 |
|
|
// |
1411 |
|
|
// Construct a Data object of the appropriate type. |
1412 |
|
|
// Construct the object first as there seems to be a bug which causes |
1413 |
|
|
// undefined behaviour if an exception is thrown during construction |
1414 |
|
|
// within the shared_ptr constructor. |
1415 |
|
|
if (expanded) { |
1416 |
|
|
DataAbstract* temp=new DataExpanded(value,what); |
1417 |
jgs |
102 |
boost::shared_ptr<DataAbstract> temp_data(temp); |
1418 |
|
|
m_data=temp_data; |
1419 |
jgs |
94 |
} else { |
1420 |
|
|
DataAbstract* temp=new DataConstant(value,what); |
1421 |
jgs |
102 |
boost::shared_ptr<DataAbstract> temp_data(temp); |
1422 |
|
|
m_data=temp_data; |
1423 |
jgs |
94 |
} |
1424 |
|
|
} |
1425 |
|
|
|
1426 |
jgs |
102 |
/** |
1427 |
|
|
Binary Data object operators. |
1428 |
|
|
*/ |
1429 |
gross |
854 |
inline double rpow(double x,double y) |
1430 |
|
|
{ |
1431 |
|
|
return pow(y,x); |
1432 |
|
|
}; |
1433 |
jgs |
94 |
|
1434 |
|
|
/** |
1435 |
|
|
\brief |
1436 |
|
|
Operator+ |
1437 |
|
|
Takes two Data objects. |
1438 |
|
|
*/ |
1439 |
woo409 |
757 |
ESCRIPT_DLL_API Data operator+(const Data& left, const Data& right); |
1440 |
jgs |
94 |
|
1441 |
|
|
/** |
1442 |
|
|
\brief |
1443 |
|
|
Operator- |
1444 |
|
|
Takes two Data objects. |
1445 |
|
|
*/ |
1446 |
woo409 |
757 |
ESCRIPT_DLL_API Data operator-(const Data& left, const Data& right); |
1447 |
jgs |
94 |
|
1448 |
|
|
/** |
1449 |
|
|
\brief |
1450 |
|
|
Operator* |
1451 |
|
|
Takes two Data objects. |
1452 |
|
|
*/ |
1453 |
woo409 |
757 |
ESCRIPT_DLL_API Data operator*(const Data& left, const Data& right); |
1454 |
jgs |
94 |
|
1455 |
|
|
/** |
1456 |
|
|
\brief |
1457 |
|
|
Operator/ |
1458 |
|
|
Takes two Data objects. |
1459 |
|
|
*/ |
1460 |
woo409 |
757 |
ESCRIPT_DLL_API Data operator/(const Data& left, const Data& right); |
1461 |
jgs |
94 |
|
1462 |
|
|
/** |
1463 |
|
|
\brief |
1464 |
|
|
Operator+ |
1465 |
|
|
Takes LHS Data object and RHS python::object. |
1466 |
|
|
python::object must be convertable to Data type. |
1467 |
|
|
*/ |
1468 |
woo409 |
757 |
ESCRIPT_DLL_API Data operator+(const Data& left, const boost::python::object& right); |
1469 |
jgs |
94 |
|
1470 |
|
|
/** |
1471 |
|
|
\brief |
1472 |
|
|
Operator- |
1473 |
|
|
Takes LHS Data object and RHS python::object. |
1474 |
|
|
python::object must be convertable to Data type. |
1475 |
|
|
*/ |
1476 |
woo409 |
757 |
ESCRIPT_DLL_API Data operator-(const Data& left, const boost::python::object& right); |
1477 |
jgs |
94 |
|
1478 |
|
|
/** |
1479 |
|
|
\brief |
1480 |
|
|
Operator* |
1481 |
|
|
Takes LHS Data object and RHS python::object. |
1482 |
|
|
python::object must be convertable to Data type. |
1483 |
|
|
*/ |
1484 |
woo409 |
757 |
ESCRIPT_DLL_API Data operator*(const Data& left, const boost::python::object& right); |
1485 |
jgs |
94 |
|
1486 |
|
|
/** |
1487 |
|
|
\brief |
1488 |
|
|
Operator/ |
1489 |
|
|
Takes LHS Data object and RHS python::object. |
1490 |
|
|
python::object must be convertable to Data type. |
1491 |
|
|
*/ |
1492 |
woo409 |
757 |
ESCRIPT_DLL_API Data operator/(const Data& left, const boost::python::object& right); |
1493 |
jgs |
94 |
|
1494 |
|
|
/** |
1495 |
|
|
\brief |
1496 |
|
|
Operator+ |
1497 |
|
|
Takes LHS python::object and RHS Data object. |
1498 |
|
|
python::object must be convertable to Data type. |
1499 |
|
|
*/ |
1500 |
woo409 |
757 |
ESCRIPT_DLL_API Data operator+(const boost::python::object& left, const Data& right); |
1501 |
jgs |
94 |
|
1502 |
|
|
/** |
1503 |
|
|
\brief |
1504 |
|
|
Operator- |
1505 |
|
|
Takes LHS python::object and RHS Data object. |
1506 |
|
|
python::object must be convertable to Data type. |
1507 |
|
|
*/ |
1508 |
woo409 |
757 |
ESCRIPT_DLL_API Data operator-(const boost::python::object& left, const Data& right); |
1509 |
jgs |
94 |
|
1510 |
|
|
/** |
1511 |
|
|
\brief |
1512 |
|
|
Operator* |
1513 |
|
|
Takes LHS python::object and RHS Data object. |
1514 |
|
|
python::object must be convertable to Data type. |
1515 |
|
|
*/ |
1516 |
woo409 |
757 |
ESCRIPT_DLL_API Data operator*(const boost::python::object& left, const Data& right); |
1517 |
jgs |
94 |
|
1518 |
|
|
/** |
1519 |
|
|
\brief |
1520 |
|
|
Operator/ |
1521 |
|
|
Takes LHS python::object and RHS Data object. |
1522 |
|
|
python::object must be convertable to Data type. |
1523 |
|
|
*/ |
1524 |
woo409 |
757 |
ESCRIPT_DLL_API Data operator/(const boost::python::object& left, const Data& right); |
1525 |
jgs |
94 |
|
1526 |
|
|
/** |
1527 |
|
|
\brief |
1528 |
|
|
Output operator |
1529 |
|
|
*/ |
1530 |
woo409 |
757 |
ESCRIPT_DLL_API std::ostream& operator<<(std::ostream& o, const Data& data); |
1531 |
jgs |
94 |
|
1532 |
|
|
/** |
1533 |
|
|
\brief |
1534 |
ksteube |
813 |
Compute a tensor product of two Data objects |
1535 |
|
|
\param arg0 - Input - Data object |
1536 |
|
|
\param arg1 - Input - Data object |
1537 |
|
|
\param axis_offset - Input - axis offset |
1538 |
|
|
\param transpose - Input - 0: transpose neither, 1: transpose arg0, 2: transpose arg1 |
1539 |
|
|
*/ |
1540 |
|
|
ESCRIPT_DLL_API |
1541 |
|
|
Data |
1542 |
|
|
C_GeneralTensorProduct(Data& arg0, |
1543 |
|
|
Data& arg1, |
1544 |
|
|
int axis_offset=0, |
1545 |
|
|
int transpose=0); |
1546 |
|
|
|
1547 |
|
|
/** |
1548 |
|
|
\brief |
1549 |
jgs |
94 |
Return true if operands are equivalent, else return false. |
1550 |
|
|
NB: this operator does very little at this point, and isn't to |
1551 |
|
|
be relied on. Requires further implementation. |
1552 |
|
|
*/ |
1553 |
woo409 |
757 |
//ESCRIPT_DLL_API bool operator==(const Data& left, const Data& right); |
1554 |
jgs |
94 |
|
1555 |
jgs |
102 |
/** |
1556 |
|
|
\brief |
1557 |
|
|
Perform the given binary operation with this and right as operands. |
1558 |
|
|
Right is a Data object. |
1559 |
|
|
*/ |
1560 |
jgs |
94 |
template <class BinaryFunction> |
1561 |
|
|
inline |
1562 |
|
|
void |
1563 |
|
|
Data::binaryOp(const Data& right, |
1564 |
|
|
BinaryFunction operation) |
1565 |
|
|
{ |
1566 |
|
|
// |
1567 |
|
|
// if this has a rank of zero promote it to the rank of the RHS |
1568 |
|
|
if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) { |
1569 |
gross |
854 |
throw DataException("Error - attempt to update rank zero object with object with rank bigger than zero."); |
1570 |
jgs |
94 |
} |
1571 |
|
|
// |
1572 |
|
|
// initially make the temporary a shallow copy |
1573 |
|
|
Data tempRight(right); |
1574 |
|
|
if (getFunctionSpace()!=right.getFunctionSpace()) { |
1575 |
|
|
if (right.probeInterpolation(getFunctionSpace())) { |
1576 |
|
|
// |
1577 |
|
|
// an interpolation is required so create a new Data |
1578 |
|
|
tempRight=Data(right,this->getFunctionSpace()); |
1579 |
|
|
} else if (probeInterpolation(right.getFunctionSpace())) { |
1580 |
|
|
// |
1581 |
|
|
// interpolate onto the RHS function space |
1582 |
|
|
Data tempLeft(*this,right.getFunctionSpace()); |
1583 |
|
|
m_data=tempLeft.m_data; |
1584 |
|
|
} |
1585 |
|
|
} |
1586 |
|
|
operandCheck(tempRight); |
1587 |
|
|
// |
1588 |
|
|
// ensure this has the right type for the RHS |
1589 |
jgs |
102 |
typeMatchRight(tempRight); |
1590 |
jgs |
94 |
// |
1591 |
|
|
// Need to cast to the concrete types so that the correct binaryOp |
1592 |
|
|
// is called. |
1593 |
|
|
if (isExpanded()) { |
1594 |
|
|
// |
1595 |
|
|
// Expanded data will be done in parallel, the right hand side can be |
1596 |
|
|
// of any data type |
1597 |
|
|
DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get()); |
1598 |
|
|
EsysAssert((leftC!=0), "Programming error - casting to DataExpanded."); |
1599 |
|
|
escript::binaryOp(*leftC,*(tempRight.m_data.get()),operation); |
1600 |
|
|
} else if (isTagged()) { |
1601 |
|
|
// |
1602 |
|
|
// Tagged data is operated on serially, the right hand side can be |
1603 |
|
|
// either DataConstant or DataTagged |
1604 |
|
|
DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get()); |
1605 |
|
|
EsysAssert((leftC!=0), "Programming error - casting to DataTagged."); |
1606 |
|
|
if (right.isTagged()) { |
1607 |
|
|
DataTagged* rightC=dynamic_cast<DataTagged*>(tempRight.m_data.get()); |
1608 |
|
|
EsysAssert((rightC!=0), "Programming error - casting to DataTagged."); |
1609 |
|
|
escript::binaryOp(*leftC,*rightC,operation); |
1610 |
|
|
} else { |
1611 |
|
|
DataConstant* rightC=dynamic_cast<DataConstant*>(tempRight.m_data.get()); |
1612 |
|
|
EsysAssert((rightC!=0), "Programming error - casting to DataConstant."); |
1613 |
|
|
escript::binaryOp(*leftC,*rightC,operation); |
1614 |
|
|
} |
1615 |
jgs |
102 |
} else if (isConstant()) { |
1616 |
jgs |
94 |
DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get()); |
1617 |
|
|
DataConstant* rightC=dynamic_cast<DataConstant*>(tempRight.m_data.get()); |
1618 |
|
|
EsysAssert((leftC!=0 && rightC!=0), "Programming error - casting to DataConstant."); |
1619 |
|
|
escript::binaryOp(*leftC,*rightC,operation); |
1620 |
|
|
} |
1621 |
gross |
854 |
#if defined DOPROF |
1622 |
|
|
profData->binary++; |
1623 |
|
|
#endif |
1624 |
jgs |
94 |
} |
1625 |
|
|
|
1626 |
jgs |
102 |
/** |
1627 |
|
|
\brief |
1628 |
|
|
Perform the given unary operation on other and return the result. |
1629 |
|
|
Given operation is performed on each element of each data point, thus |
1630 |
|
|
argument object is a rank n Data object, and returned object is a rank n |
1631 |
|
|
Data object. |
1632 |
|
|
Calls Data::unaryOp. |
1633 |
|
|
*/ |
1634 |
jgs |
94 |
template <class UnaryFunction> |
1635 |
|
|
inline |
1636 |
jgs |
102 |
Data |
1637 |
|
|
unaryOp(const Data& other, |
1638 |
|
|
UnaryFunction operation) |
1639 |
|
|
{ |
1640 |
|
|
Data result; |
1641 |
|
|
result.copy(other); |
1642 |
|
|
result.unaryOp(operation); |
1643 |
|
|
return result; |
1644 |
|
|
} |
1645 |
|
|
|
1646 |
|
|
/** |
1647 |
|
|
\brief |
1648 |
|
|
Perform the given unary operation on this. |
1649 |
|
|
Given operation is performed on each element of each data point. |
1650 |
|
|
Calls escript::unaryOp. |
1651 |
|
|
*/ |
1652 |
|
|
template <class UnaryFunction> |
1653 |
|
|
inline |
1654 |
jgs |
94 |
void |
1655 |
|
|
Data::unaryOp(UnaryFunction operation) |
1656 |
|
|
{ |
1657 |
|
|
if (isExpanded()) { |
1658 |
|
|
DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get()); |
1659 |
|
|
EsysAssert((leftC!=0), "Programming error - casting to DataExpanded."); |
1660 |
|
|
escript::unaryOp(*leftC,operation); |
1661 |
|
|
} else if (isTagged()) { |
1662 |
|
|
DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get()); |
1663 |
|
|
EsysAssert((leftC!=0), "Programming error - casting to DataTagged."); |
1664 |
|
|
escript::unaryOp(*leftC,operation); |
1665 |
jgs |
102 |
} else if (isConstant()) { |
1666 |
jgs |
94 |
DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get()); |
1667 |
|
|
EsysAssert((leftC!=0), "Programming error - casting to DataConstant."); |
1668 |
|
|
escript::unaryOp(*leftC,operation); |
1669 |
|
|
} |
1670 |
|
|
} |
1671 |
|
|
|
1672 |
jgs |
102 |
/** |
1673 |
|
|
\brief |
1674 |
|
|
Perform the given Data object reduction algorithm on this and return the result. |
1675 |
|
|
Given operation combines each element of each data point, thus argument |
1676 |
|
|
object (*this) is a rank n Data object, and returned object is a scalar. |
1677 |
|
|
Calls escript::algorithm. |
1678 |
|
|
*/ |
1679 |
jgs |
147 |
template <class BinaryFunction> |
1680 |
jgs |
94 |
inline |
1681 |
|
|
double |
1682 |
jgs |
147 |
Data::algorithm(BinaryFunction operation, double initial_value) const |
1683 |
jgs |
94 |
{ |
1684 |
|
|
if (isExpanded()) { |
1685 |
|
|
DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get()); |
1686 |
|
|
EsysAssert((leftC!=0), "Programming error - casting to DataExpanded."); |
1687 |
jgs |
147 |
return escript::algorithm(*leftC,operation,initial_value); |
1688 |
jgs |
102 |
} else if (isTagged()) { |
1689 |
jgs |
94 |
DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get()); |
1690 |
|
|
EsysAssert((leftC!=0), "Programming error - casting to DataTagged."); |
1691 |
jgs |
147 |
return escript::algorithm(*leftC,operation,initial_value); |
1692 |
jgs |
102 |
} else if (isConstant()) { |
1693 |
jgs |
94 |
DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get()); |
1694 |
|
|
EsysAssert((leftC!=0), "Programming error - casting to DataConstant."); |
1695 |
jgs |
147 |
return escript::algorithm(*leftC,operation,initial_value); |
1696 |
jgs |
94 |
} |
1697 |
jgs |
102 |
return 0; |
1698 |
jgs |
94 |
} |
1699 |
|
|
|
1700 |
jgs |
102 |
/** |
1701 |
|
|
\brief |
1702 |
|
|
Perform the given data point reduction algorithm on data and return the result. |
1703 |
|
|
Given operation combines each element within each data point into a scalar, |
1704 |
|
|
thus argument object is a rank n Data object, and returned object is a |
1705 |
|
|
rank 0 Data object. |
1706 |
|
|
Calls escript::dp_algorithm. |
1707 |
|
|
*/ |
1708 |
jgs |
147 |
template <class BinaryFunction> |
1709 |
jgs |
94 |
inline |
1710 |
|
|
Data |
1711 |
jgs |
147 |
Data::dp_algorithm(BinaryFunction operation, double initial_value) const |
1712 |
jgs |
94 |
{ |
1713 |
jgs |
106 |
if (isExpanded()) { |
1714 |
jgs |
559 |
Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded()); |
1715 |
jgs |
106 |
DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get()); |
1716 |
jgs |
102 |
DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get()); |
1717 |
|
|
EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded."); |
1718 |
|
|
EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded."); |
1719 |
jgs |
147 |
escript::dp_algorithm(*dataE,*resultE,operation,initial_value); |
1720 |
jgs |
559 |
return result; |
1721 |
jgs |
106 |
} else if (isTagged()) { |
1722 |
|
|
DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get()); |
1723 |
jgs |
562 |
DataArrayView::ShapeType viewShape; |
1724 |
|
|
DataArrayView::ValueType viewData(1); |
1725 |
|
|
viewData[0]=0; |
1726 |
|
|
DataArrayView defaultValue(viewData,viewShape); |
1727 |
jgs |
559 |
DataTagged::TagListType keys; |
1728 |
jgs |
562 |
DataTagged::ValueListType values; |
1729 |
jgs |
559 |
DataTagged::DataMapType::const_iterator i; |
1730 |
|
|
for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) { |
1731 |
|
|
keys.push_back(i->first); |
1732 |
jgs |
562 |
values.push_back(defaultValue); |
1733 |
jgs |
559 |
} |
1734 |
|
|
Data result(keys,values,defaultValue,getFunctionSpace()); |
1735 |
jgs |
102 |
DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get()); |
1736 |
|
|
EsysAssert((dataT!=0), "Programming error - casting data to DataTagged."); |
1737 |
|
|
EsysAssert((resultT!=0), "Programming error - casting result to DataTagged."); |
1738 |
jgs |
147 |
escript::dp_algorithm(*dataT,*resultT,operation,initial_value); |
1739 |
jgs |
559 |
return result; |
1740 |
jgs |
106 |
} else if (isConstant()) { |
1741 |
jgs |
559 |
Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded()); |
1742 |
jgs |
106 |
DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get()); |
1743 |
jgs |
102 |
DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get()); |
1744 |
|
|
EsysAssert((dataC!=0), "Programming error - casting data to DataConstant."); |
1745 |
|
|
EsysAssert((resultC!=0), "Programming error - casting result to DataConstant."); |
1746 |
jgs |
147 |
escript::dp_algorithm(*dataC,*resultC,operation,initial_value); |
1747 |
jgs |
559 |
return result; |
1748 |
jgs |
102 |
} |
1749 |
jgs |
559 |
Data falseRetVal; // to keep compiler quiet |
1750 |
|
|
return falseRetVal; |
1751 |
jgs |
94 |
} |
1752 |
|
|
|
1753 |
|
|
} |
1754 |
|
|
#endif |