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