15 |
|
|
16 |
#ifndef DATA_H |
#ifndef DATA_H |
17 |
#define DATA_H |
#define DATA_H |
18 |
|
#include "system_dep.h" |
19 |
|
|
20 |
#include "DataAbstract.h" |
#include "DataAbstract.h" |
21 |
#include "DataAlgorithm.h" |
#include "DataAlgorithm.h" |
26 |
|
|
27 |
extern "C" { |
extern "C" { |
28 |
#include "DataC.h" |
#include "DataC.h" |
29 |
|
#include "paso/Paso.h" |
30 |
} |
} |
31 |
|
|
32 |
|
#ifndef PASO_MPI |
33 |
|
#define MPI_Comm long |
34 |
|
#endif |
35 |
|
|
36 |
#include <string> |
#include <string> |
37 |
#include <algorithm> |
#include <algorithm> |
38 |
|
|
70 |
typedef double (*UnaryDFunPtr)(double); |
typedef double (*UnaryDFunPtr)(double); |
71 |
typedef double (*BinaryDFunPtr)(double,double); |
typedef double (*BinaryDFunPtr)(double,double); |
72 |
|
|
73 |
|
|
74 |
/** |
/** |
75 |
Constructors. |
Constructors. |
76 |
*/ |
*/ |
80 |
Default constructor. |
Default constructor. |
81 |
Creates a DataEmpty object. |
Creates a DataEmpty object. |
82 |
*/ |
*/ |
83 |
|
ESCRIPT_DLL_API |
84 |
Data(); |
Data(); |
85 |
|
|
86 |
/** |
/** |
88 |
Copy constructor. |
Copy constructor. |
89 |
WARNING: Only performs a shallow copy. |
WARNING: Only performs a shallow copy. |
90 |
*/ |
*/ |
91 |
|
ESCRIPT_DLL_API |
92 |
Data(const Data& inData); |
Data(const Data& inData); |
93 |
|
|
94 |
/** |
/** |
97 |
function space of inData the inData are tried to be interpolated to what, |
function space of inData the inData are tried to be interpolated to what, |
98 |
otherwise a shallow copy of inData is returned. |
otherwise a shallow copy of inData is returned. |
99 |
*/ |
*/ |
100 |
|
ESCRIPT_DLL_API |
101 |
Data(const Data& inData, |
Data(const Data& inData, |
102 |
const FunctionSpace& what); |
const FunctionSpace& what); |
103 |
|
|
111 |
the value. Otherwise a more efficient storage |
the value. Otherwise a more efficient storage |
112 |
mechanism will be used. |
mechanism will be used. |
113 |
*/ |
*/ |
114 |
|
ESCRIPT_DLL_API |
115 |
Data(const DataArrayView& value, |
Data(const DataArrayView& value, |
116 |
const FunctionSpace& what=FunctionSpace(), |
const FunctionSpace& what=FunctionSpace(), |
117 |
bool expanded=false); |
bool expanded=false); |
127 |
the given value. Otherwise a more efficient storage |
the given value. Otherwise a more efficient storage |
128 |
mechanism will be used. |
mechanism will be used. |
129 |
*/ |
*/ |
130 |
|
ESCRIPT_DLL_API |
131 |
Data(double value, |
Data(double value, |
132 |
const DataArrayView::ShapeType& dataPointShape=DataArrayView::ShapeType(), |
const DataArrayView::ShapeType& dataPointShape=DataArrayView::ShapeType(), |
133 |
const FunctionSpace& what=FunctionSpace(), |
const FunctionSpace& what=FunctionSpace(), |
140 |
\param inData - Input - Input Data object. |
\param inData - Input - Input Data object. |
141 |
\param region - Input - Region to copy. |
\param region - Input - Region to copy. |
142 |
*/ |
*/ |
143 |
|
ESCRIPT_DLL_API |
144 |
Data(const Data& inData, |
Data(const Data& inData, |
145 |
const DataArrayView::RegionType& region); |
const DataArrayView::RegionType& region); |
146 |
|
|
158 |
the appropriate values. |
the appropriate values. |
159 |
==>* |
==>* |
160 |
*/ |
*/ |
161 |
|
ESCRIPT_DLL_API |
162 |
Data(const DataTagged::TagListType& tagKeys, |
Data(const DataTagged::TagListType& tagKeys, |
163 |
const DataTagged::ValueListType& values, |
const DataTagged::ValueListType& values, |
164 |
const DataArrayView& defaultValue, |
const DataArrayView& defaultValue, |
175 |
the value. Otherwise a more efficient storage |
the value. Otherwise a more efficient storage |
176 |
mechanism will be used. |
mechanism will be used. |
177 |
*/ |
*/ |
178 |
|
ESCRIPT_DLL_API |
179 |
Data(const boost::python::numeric::array& value, |
Data(const boost::python::numeric::array& value, |
180 |
const FunctionSpace& what=FunctionSpace(), |
const FunctionSpace& what=FunctionSpace(), |
181 |
bool expanded=false); |
bool expanded=false); |
191 |
the value. Otherwise a more efficient storage |
the value. Otherwise a more efficient storage |
192 |
mechanism will be used. |
mechanism will be used. |
193 |
*/ |
*/ |
194 |
|
ESCRIPT_DLL_API |
195 |
Data(const boost::python::object& value, |
Data(const boost::python::object& value, |
196 |
const FunctionSpace& what=FunctionSpace(), |
const FunctionSpace& what=FunctionSpace(), |
197 |
bool expanded=false); |
bool expanded=false); |
205 |
\param value - Input - Input data. |
\param value - Input - Input data. |
206 |
\param other - Input - contains all other parameters. |
\param other - Input - contains all other parameters. |
207 |
*/ |
*/ |
208 |
|
ESCRIPT_DLL_API |
209 |
Data(const boost::python::object& value, |
Data(const boost::python::object& value, |
210 |
const Data& other); |
const Data& other); |
211 |
|
|
213 |
\brief |
\brief |
214 |
Constructor which creates a DataConstant of "shape" with constant value. |
Constructor which creates a DataConstant of "shape" with constant value. |
215 |
*/ |
*/ |
216 |
|
ESCRIPT_DLL_API |
217 |
Data(double value, |
Data(double value, |
218 |
const boost::python::tuple& shape=boost::python::make_tuple(), |
const boost::python::tuple& shape=boost::python::make_tuple(), |
219 |
const FunctionSpace& what=FunctionSpace(), |
const FunctionSpace& what=FunctionSpace(), |
222 |
\brief |
\brief |
223 |
Destructor |
Destructor |
224 |
*/ |
*/ |
225 |
|
ESCRIPT_DLL_API |
226 |
~Data(); |
~Data(); |
227 |
|
|
228 |
/** |
/** |
229 |
\brief |
\brief |
230 |
Perform a deep copy. |
Perform a deep copy. |
231 |
*/ |
*/ |
232 |
|
ESCRIPT_DLL_API |
233 |
void |
void |
234 |
copy(const Data& other); |
copy(const Data& other); |
235 |
|
|
239 |
|
|
240 |
/** |
/** |
241 |
\brief |
\brief |
242 |
|
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 |
Return the values of all data-points as a single python numarray object. |
Return the values of all data-points as a single python numarray object. |
260 |
*/ |
*/ |
261 |
|
ESCRIPT_DLL_API |
262 |
const boost::python::numeric::array |
const boost::python::numeric::array |
263 |
convertToNumArray(); |
convertToNumArray(); |
264 |
|
|
265 |
/** |
/** |
266 |
\brief |
\brief |
267 |
Return the values of all data-points for the given sample as a single python numarray object. |
Fills the expanded Data object from values of a python numarray object. |
268 |
*/ |
*/ |
269 |
const boost::python::numeric::array |
ESCRIPT_DLL_API |
270 |
convertToNumArrayFromSampleNo(int sampleNo); |
void |
271 |
|
fillFromNumArray(const boost::python::numeric::array); |
272 |
|
|
273 |
/** |
/** |
274 |
\brief |
\brief |
275 |
Return the value of the specified data-point as a single python numarray object. |
Return the values of a data point on this process |
276 |
*/ |
*/ |
277 |
|
ESCRIPT_DLL_API |
278 |
const boost::python::numeric::array |
const boost::python::numeric::array |
279 |
convertToNumArrayFromDPNo(int sampleNo, |
getValueOfDataPoint(int dataPointNo); |
|
int dataPointNo); |
|
280 |
|
|
281 |
/** |
/** |
282 |
\brief |
\brief |
283 |
Fills the expanded Data object from values of a python numarray object. |
sets the values of a data-point on this process |
284 |
*/ |
*/ |
285 |
|
ESCRIPT_DLL_API |
286 |
void |
void |
287 |
fillFromNumArray(const boost::python::numeric::array); |
setValueOfDataPointToArray(int dataPointNo, const boost::python::numeric::array); |
288 |
|
|
289 |
|
/** |
290 |
|
\brief |
291 |
|
sets the values of a data-point on this process |
292 |
|
*/ |
293 |
|
ESCRIPT_DLL_API |
294 |
|
void |
295 |
|
setValueOfDataPoint(int dataPointNo, const double); |
296 |
|
|
297 |
|
/** |
298 |
|
\brief |
299 |
|
Return the value of the specified data-point across all processors |
300 |
|
*/ |
301 |
|
ESCRIPT_DLL_API |
302 |
|
const boost::python::numeric::array |
303 |
|
getValueOfGlobalDataPoint(int procNo, int dataPointNo); |
304 |
|
|
305 |
/** |
/** |
306 |
\brief |
\brief |
309 |
The data-point number here corresponds to the data-point number in the |
The data-point number here corresponds to the data-point number in the |
310 |
numarray returned by convertToNumArray. |
numarray returned by convertToNumArray. |
311 |
*/ |
*/ |
312 |
|
ESCRIPT_DLL_API |
313 |
int |
int |
314 |
getTagNumber(int dpno); |
getTagNumber(int dpno); |
315 |
|
|
317 |
\brief |
\brief |
318 |
Return the C wrapper for the Data object. |
Return the C wrapper for the Data object. |
319 |
*/ |
*/ |
320 |
|
ESCRIPT_DLL_API |
321 |
escriptDataC |
escriptDataC |
322 |
getDataC(); |
getDataC(); |
323 |
|
|
325 |
\brief |
\brief |
326 |
Return the C wrapper for the Data object - const version. |
Return the C wrapper for the Data object - const version. |
327 |
*/ |
*/ |
328 |
|
ESCRIPT_DLL_API |
329 |
escriptDataC |
escriptDataC |
330 |
getDataC() const; |
getDataC() const; |
331 |
|
|
333 |
\brief |
\brief |
334 |
Write the data as a string. |
Write the data as a string. |
335 |
*/ |
*/ |
336 |
|
ESCRIPT_DLL_API |
337 |
inline |
inline |
338 |
std::string |
std::string |
339 |
toString() const |
toString() const |
347 |
the shape information for each data point although it also may be used |
the shape information for each data point although it also may be used |
348 |
to manipulate the point data. |
to manipulate the point data. |
349 |
*/ |
*/ |
350 |
|
ESCRIPT_DLL_API |
351 |
inline |
inline |
352 |
const DataArrayView& |
const DataArrayView& |
353 |
getPointDataView() const |
getPointDataView() const |
359 |
\brief |
\brief |
360 |
Whatever the current Data type make this into a DataExpanded. |
Whatever the current Data type make this into a DataExpanded. |
361 |
*/ |
*/ |
362 |
|
ESCRIPT_DLL_API |
363 |
void |
void |
364 |
expand(); |
expand(); |
365 |
|
|
370 |
Expanded data to tagged will throw an exception. |
Expanded data to tagged will throw an exception. |
371 |
==>* |
==>* |
372 |
*/ |
*/ |
373 |
|
ESCRIPT_DLL_API |
374 |
void |
void |
375 |
tag(); |
tag(); |
376 |
|
|
378 |
\brief |
\brief |
379 |
Return true if this Data is expanded. |
Return true if this Data is expanded. |
380 |
*/ |
*/ |
381 |
|
ESCRIPT_DLL_API |
382 |
bool |
bool |
383 |
isExpanded() const; |
isExpanded() const; |
384 |
|
|
386 |
\brief |
\brief |
387 |
Return true if this Data is tagged. |
Return true if this Data is tagged. |
388 |
*/ |
*/ |
389 |
|
ESCRIPT_DLL_API |
390 |
bool |
bool |
391 |
isTagged() const; |
isTagged() const; |
392 |
|
|
394 |
\brief |
\brief |
395 |
Return true if this Data is constant. |
Return true if this Data is constant. |
396 |
*/ |
*/ |
397 |
|
ESCRIPT_DLL_API |
398 |
bool |
bool |
399 |
isConstant() const; |
isConstant() const; |
400 |
|
|
402 |
\brief |
\brief |
403 |
Return true if this Data is empty. |
Return true if this Data is empty. |
404 |
*/ |
*/ |
405 |
|
ESCRIPT_DLL_API |
406 |
bool |
bool |
407 |
isEmpty() const; |
isEmpty() const; |
408 |
|
|
410 |
\brief |
\brief |
411 |
Return the function space. |
Return the function space. |
412 |
*/ |
*/ |
413 |
|
ESCRIPT_DLL_API |
414 |
inline |
inline |
415 |
const FunctionSpace& |
const FunctionSpace& |
416 |
getFunctionSpace() const |
getFunctionSpace() const |
422 |
\brief |
\brief |
423 |
Return a copy of the function space. |
Return a copy of the function space. |
424 |
*/ |
*/ |
425 |
|
ESCRIPT_DLL_API |
426 |
const FunctionSpace |
const FunctionSpace |
427 |
getCopyOfFunctionSpace() const; |
getCopyOfFunctionSpace() const; |
428 |
|
|
430 |
\brief |
\brief |
431 |
Return the domain. |
Return the domain. |
432 |
*/ |
*/ |
433 |
|
ESCRIPT_DLL_API |
434 |
inline |
inline |
435 |
const AbstractDomain& |
const AbstractDomain& |
436 |
getDomain() const |
getDomain() const |
442 |
\brief |
\brief |
443 |
Return a copy of the domain. |
Return a copy of the domain. |
444 |
*/ |
*/ |
445 |
|
ESCRIPT_DLL_API |
446 |
const AbstractDomain |
const AbstractDomain |
447 |
getCopyOfDomain() const; |
getCopyOfDomain() const; |
448 |
|
|
450 |
\brief |
\brief |
451 |
Return the rank of the point data. |
Return the rank of the point data. |
452 |
*/ |
*/ |
453 |
|
ESCRIPT_DLL_API |
454 |
inline |
inline |
455 |
int |
int |
456 |
getDataPointRank() const |
getDataPointRank() const |
460 |
|
|
461 |
/** |
/** |
462 |
\brief |
\brief |
463 |
|
Return the number of data points |
464 |
|
*/ |
465 |
|
ESCRIPT_DLL_API |
466 |
|
inline |
467 |
|
int |
468 |
|
getNumDataPoints() const |
469 |
|
{ |
470 |
|
return getNumSamples() * getNumDataPointsPerSample(); |
471 |
|
} |
472 |
|
/** |
473 |
|
\brief |
474 |
Return the number of samples. |
Return the number of samples. |
475 |
*/ |
*/ |
476 |
|
ESCRIPT_DLL_API |
477 |
inline |
inline |
478 |
int |
int |
479 |
getNumSamples() const |
getNumSamples() const |
485 |
\brief |
\brief |
486 |
Return the number of data points per sample. |
Return the number of data points per sample. |
487 |
*/ |
*/ |
488 |
|
ESCRIPT_DLL_API |
489 |
inline |
inline |
490 |
int |
int |
491 |
getNumDataPointsPerSample() const |
getNumDataPointsPerSample() const |
492 |
{ |
{ |
493 |
return m_data->getNumDPPSample(); |
return m_data->getNumDPPSample(); |
494 |
} |
} |
495 |
|
/** |
496 |
|
\brief |
497 |
|
dumps the object into a netCDF file |
498 |
|
*/ |
499 |
|
ESCRIPT_DLL_API |
500 |
|
inline |
501 |
|
void |
502 |
|
dump(const std::string fileName) const |
503 |
|
{ |
504 |
|
return m_data->dump(fileName); |
505 |
|
} |
506 |
|
|
507 |
/** |
/** |
508 |
\brief |
\brief |
510 |
preferred interface but is provided for use by C code. |
preferred interface but is provided for use by C code. |
511 |
\param sampleNo - Input - the given sample no. |
\param sampleNo - Input - the given sample no. |
512 |
*/ |
*/ |
513 |
|
ESCRIPT_DLL_API |
514 |
inline |
inline |
515 |
DataAbstract::ValueType::value_type* |
DataAbstract::ValueType::value_type* |
516 |
getSampleData(DataAbstract::ValueType::size_type sampleNo) |
getSampleData(DataAbstract::ValueType::size_type sampleNo) |
524 |
access data that isn't tagged an exception will be thrown. |
access data that isn't tagged an exception will be thrown. |
525 |
\param tag - Input - the tag key. |
\param tag - Input - the tag key. |
526 |
*/ |
*/ |
527 |
|
ESCRIPT_DLL_API |
528 |
inline |
inline |
529 |
DataAbstract::ValueType::value_type* |
DataAbstract::ValueType::value_type* |
530 |
getSampleDataByTag(int tag) |
getSampleDataByTag(int tag) |
534 |
|
|
535 |
/** |
/** |
536 |
\brief |
\brief |
|
Assign the given value to the data-points referenced by the given |
|
|
reference number. |
|
|
|
|
|
The value supplied is a python numarray object. The data from this numarray |
|
|
is unpacked into a DataArray, and this is used to set the corresponding |
|
|
data-points in the underlying Data object. |
|
|
|
|
|
If the underlying Data object cannot be accessed via reference numbers, an |
|
|
exception will be thrown. |
|
|
|
|
|
\param ref - Input - reference number. |
|
|
\param value - Input - value to assign to data-points associated with |
|
|
the given reference number. |
|
|
*/ |
|
|
void |
|
|
setRefValue(int ref, |
|
|
const boost::python::numeric::array& value); |
|
|
|
|
|
/** |
|
|
\brief |
|
|
Return the values associated with the data-points referenced by the given |
|
|
reference number. |
|
|
|
|
|
The value supplied is a python numarray object. The data from the corresponding |
|
|
data-points in this Data object are packed into the given numarray object. |
|
|
|
|
|
If the underlying Data object cannot be accessed via reference numbers, an |
|
|
exception will be thrown. |
|
|
|
|
|
\param ref - Input - reference number. |
|
|
\param value - Output - object to receive values from data-points |
|
|
associated with the given reference number. |
|
|
*/ |
|
|
void |
|
|
getRefValue(int ref, |
|
|
boost::python::numeric::array& value); |
|
|
|
|
|
/** |
|
|
\brief |
|
537 |
Return a view into the data for the data point specified. |
Return a view into the data for the data point specified. |
538 |
NOTE: Construction of the DataArrayView is a relatively expensive |
NOTE: Construction of the DataArrayView is a relatively expensive |
539 |
operation. |
operation. |
540 |
\param sampleNo - Input - |
\param sampleNo - Input - |
541 |
\param dataPointNo - Input - |
\param dataPointNo - Input - |
542 |
*/ |
*/ |
543 |
|
ESCRIPT_DLL_API |
544 |
inline |
inline |
545 |
DataArrayView |
DataArrayView |
546 |
getDataPoint(int sampleNo, |
getDataPoint(int sampleNo, |
547 |
int dataPointNo) |
int dataPointNo) |
548 |
{ |
{ |
549 |
return m_data->getDataPoint(sampleNo,dataPointNo); |
return m_data->getDataPoint(sampleNo,dataPointNo); |
550 |
} |
} |
551 |
|
|
552 |
/** |
/** |
553 |
\brief |
\brief |
554 |
Return a reference to the data point shape. |
Return a reference to the data point shape. |
555 |
*/ |
*/ |
556 |
|
ESCRIPT_DLL_API |
557 |
const DataArrayView::ShapeType& |
const DataArrayView::ShapeType& |
558 |
getDataPointShape() const; |
getDataPointShape() const; |
559 |
|
|
561 |
\brief |
\brief |
562 |
Return the data point shape as a tuple of integers. |
Return the data point shape as a tuple of integers. |
563 |
*/ |
*/ |
564 |
|
ESCRIPT_DLL_API |
565 |
const boost::python::tuple |
const boost::python::tuple |
566 |
getShapeTuple() const; |
getShapeTuple() const; |
567 |
|
|
570 |
Return the size of the data point. It is the product of the |
Return the size of the data point. It is the product of the |
571 |
data point shape dimensions. |
data point shape dimensions. |
572 |
*/ |
*/ |
573 |
|
ESCRIPT_DLL_API |
574 |
int |
int |
575 |
getDataPointSize() const; |
getDataPointSize() const; |
576 |
|
|
578 |
\brief |
\brief |
579 |
Return the number of doubles stored for this Data. |
Return the number of doubles stored for this Data. |
580 |
*/ |
*/ |
581 |
|
ESCRIPT_DLL_API |
582 |
DataArrayView::ValueType::size_type |
DataArrayView::ValueType::size_type |
583 |
getLength() const; |
getLength() const; |
584 |
|
|
591 |
\param value - Input - Value to associate with given key. |
\param value - Input - Value to associate with given key. |
592 |
==>* |
==>* |
593 |
*/ |
*/ |
594 |
|
ESCRIPT_DLL_API |
595 |
void |
void |
596 |
setTaggedValue(int tagKey, |
setTaggedValue(int tagKey, |
597 |
const boost::python::object& value); |
const boost::python::object& value); |
605 |
\param value - Input - Value to associate with given key. |
\param value - Input - Value to associate with given key. |
606 |
==>* |
==>* |
607 |
*/ |
*/ |
608 |
|
ESCRIPT_DLL_API |
609 |
void |
void |
610 |
setTaggedValueFromCPP(int tagKey, |
setTaggedValueFromCPP(int tagKey, |
611 |
const DataArrayView& value); |
const DataArrayView& value); |
614 |
\brief |
\brief |
615 |
Copy other Data object into this Data object where mask is positive. |
Copy other Data object into this Data object where mask is positive. |
616 |
*/ |
*/ |
617 |
|
ESCRIPT_DLL_API |
618 |
void |
void |
619 |
copyWithMask(const Data& other, |
copyWithMask(const Data& other, |
620 |
const Data& mask); |
const Data& mask); |
629 |
the result as a Data object. |
the result as a Data object. |
630 |
* |
* |
631 |
*/ |
*/ |
632 |
|
ESCRIPT_DLL_API |
633 |
Data |
Data |
634 |
interpolate(const FunctionSpace& functionspace) const; |
interpolate(const FunctionSpace& functionspace) const; |
635 |
|
|
639 |
If functionspace is not present the function space of Function(getDomain()) is used. |
If functionspace is not present the function space of Function(getDomain()) is used. |
640 |
* |
* |
641 |
*/ |
*/ |
642 |
|
ESCRIPT_DLL_API |
643 |
Data |
Data |
644 |
gradOn(const FunctionSpace& functionspace) const; |
gradOn(const FunctionSpace& functionspace) const; |
645 |
|
|
646 |
|
ESCRIPT_DLL_API |
647 |
Data |
Data |
648 |
grad() const; |
grad() const; |
649 |
|
|
652 |
Calculate the integral over the function space domain. |
Calculate the integral over the function space domain. |
653 |
* |
* |
654 |
*/ |
*/ |
655 |
|
ESCRIPT_DLL_API |
656 |
boost::python::numeric::array |
boost::python::numeric::array |
657 |
integrate() const; |
integrate() const; |
658 |
|
|
659 |
/** |
/** |
660 |
\brief |
\brief |
661 |
|
Returns 1./ Data object |
662 |
|
* |
663 |
|
*/ |
664 |
|
ESCRIPT_DLL_API |
665 |
|
Data |
666 |
|
oneOver() const; |
667 |
|
/** |
668 |
|
\brief |
669 |
Return a Data with a 1 for +ive values and a 0 for 0 or -ive values. |
Return a Data with a 1 for +ive values and a 0 for 0 or -ive values. |
670 |
* |
* |
671 |
*/ |
*/ |
672 |
|
ESCRIPT_DLL_API |
673 |
Data |
Data |
674 |
wherePositive() const; |
wherePositive() const; |
675 |
|
|
678 |
Return a Data with a 1 for -ive values and a 0 for +ive or 0 values. |
Return a Data with a 1 for -ive values and a 0 for +ive or 0 values. |
679 |
* |
* |
680 |
*/ |
*/ |
681 |
|
ESCRIPT_DLL_API |
682 |
Data |
Data |
683 |
whereNegative() const; |
whereNegative() const; |
684 |
|
|
687 |
Return a Data with a 1 for +ive or 0 values and a 0 for -ive values. |
Return a Data with a 1 for +ive or 0 values and a 0 for -ive values. |
688 |
* |
* |
689 |
*/ |
*/ |
690 |
|
ESCRIPT_DLL_API |
691 |
Data |
Data |
692 |
whereNonNegative() const; |
whereNonNegative() const; |
693 |
|
|
696 |
Return a Data with a 1 for -ive or 0 values and a 0 for +ive values. |
Return a Data with a 1 for -ive or 0 values and a 0 for +ive values. |
697 |
* |
* |
698 |
*/ |
*/ |
699 |
|
ESCRIPT_DLL_API |
700 |
Data |
Data |
701 |
whereNonPositive() const; |
whereNonPositive() const; |
702 |
|
|
705 |
Return a Data with a 1 for 0 values and a 0 for +ive or -ive values. |
Return a Data with a 1 for 0 values and a 0 for +ive or -ive values. |
706 |
* |
* |
707 |
*/ |
*/ |
708 |
|
ESCRIPT_DLL_API |
709 |
Data |
Data |
710 |
whereZero(double tol=0.0) const; |
whereZero(double tol=0.0) const; |
711 |
|
|
714 |
Return a Data with a 0 for 0 values and a 1 for +ive or -ive values. |
Return a Data with a 0 for 0 values and a 1 for +ive or -ive values. |
715 |
* |
* |
716 |
*/ |
*/ |
717 |
|
ESCRIPT_DLL_API |
718 |
Data |
Data |
719 |
whereNonZero(double tol=0.0) const; |
whereNonZero(double tol=0.0) const; |
720 |
|
|
723 |
Return the maximum absolute value of this Data object. |
Return the maximum absolute value of this Data object. |
724 |
* |
* |
725 |
*/ |
*/ |
726 |
|
ESCRIPT_DLL_API |
727 |
double |
double |
728 |
Lsup() const; |
Lsup() const; |
729 |
|
|
732 |
Return the minimum absolute value of this Data object. |
Return the minimum absolute value of this Data object. |
733 |
* |
* |
734 |
*/ |
*/ |
735 |
|
ESCRIPT_DLL_API |
736 |
double |
double |
737 |
Linf() const; |
Linf() const; |
738 |
|
|
741 |
Return the maximum value of this Data object. |
Return the maximum value of this Data object. |
742 |
* |
* |
743 |
*/ |
*/ |
744 |
|
ESCRIPT_DLL_API |
745 |
double |
double |
746 |
sup() const; |
sup() const; |
747 |
|
|
750 |
Return the minimum value of this Data object. |
Return the minimum value of this Data object. |
751 |
* |
* |
752 |
*/ |
*/ |
753 |
|
ESCRIPT_DLL_API |
754 |
double |
double |
755 |
inf() const; |
inf() const; |
756 |
|
|
759 |
Return the absolute value of each data point of this Data object. |
Return the absolute value of each data point of this Data object. |
760 |
* |
* |
761 |
*/ |
*/ |
762 |
|
ESCRIPT_DLL_API |
763 |
Data |
Data |
764 |
abs() const; |
abs() const; |
765 |
|
|
768 |
Return the maximum value of each data point of this Data object. |
Return the maximum value of each data point of this Data object. |
769 |
* |
* |
770 |
*/ |
*/ |
771 |
|
ESCRIPT_DLL_API |
772 |
Data |
Data |
773 |
maxval() const; |
maxval() const; |
774 |
|
|
777 |
Return the minimum value of each data point of this Data object. |
Return the minimum value of each data point of this Data object. |
778 |
* |
* |
779 |
*/ |
*/ |
780 |
|
ESCRIPT_DLL_API |
781 |
Data |
Data |
782 |
minval() const; |
minval() const; |
783 |
|
|
786 |
Return the (sample number, data-point number) of the data point with |
Return the (sample number, data-point number) of the data point with |
787 |
the minimum value in this Data object. |
the minimum value in this Data object. |
788 |
*/ |
*/ |
789 |
|
ESCRIPT_DLL_API |
790 |
const boost::python::tuple |
const boost::python::tuple |
791 |
mindp() const; |
minGlobalDataPoint() const; |
792 |
|
|
793 |
|
ESCRIPT_DLL_API |
794 |
void |
void |
795 |
calc_mindp(int& SampleNo, |
calc_minGlobalDataPoint(int& ProcNo, int& DataPointNo) const; |
|
int& DataPointNo) const; |
|
|
|
|
796 |
/** |
/** |
797 |
\brief |
\brief |
798 |
Return the sign of each data point of this Data object. |
Return the sign of each data point of this Data object. |
799 |
-1 for negative values, zero for zero values, 1 for positive values. |
-1 for negative values, zero for zero values, 1 for positive values. |
800 |
* |
* |
801 |
*/ |
*/ |
802 |
|
ESCRIPT_DLL_API |
803 |
Data |
Data |
804 |
sign() const; |
sign() const; |
805 |
|
|
806 |
/** |
/** |
807 |
\brief |
\brief |
808 |
|
Return the symmetric part of a matrix which is half the matrix plus its transpose. |
809 |
|
* |
810 |
|
*/ |
811 |
|
ESCRIPT_DLL_API |
812 |
|
Data |
813 |
|
symmetric() const; |
814 |
|
|
815 |
|
/** |
816 |
|
\brief |
817 |
|
Return the nonsymmetric part of a matrix which is half the matrix minus its transpose. |
818 |
|
* |
819 |
|
*/ |
820 |
|
ESCRIPT_DLL_API |
821 |
|
Data |
822 |
|
nonsymmetric() const; |
823 |
|
|
824 |
|
/** |
825 |
|
\brief |
826 |
|
Return the trace of a matrix |
827 |
|
* |
828 |
|
*/ |
829 |
|
ESCRIPT_DLL_API |
830 |
|
Data |
831 |
|
trace(int axis_offset) const; |
832 |
|
|
833 |
|
/** |
834 |
|
\brief |
835 |
|
Transpose each data point of this Data object around the given axis. |
836 |
|
* |
837 |
|
*/ |
838 |
|
ESCRIPT_DLL_API |
839 |
|
Data |
840 |
|
transpose(int axis_offset) const; |
841 |
|
|
842 |
|
/** |
843 |
|
\brief |
844 |
Return the eigenvalues of the symmetric part at each data point of this Data object in increasing values. |
Return the eigenvalues of the symmetric part at each data point of this Data object in increasing values. |
845 |
Currently this function is restricted to rank 2, square shape, and dimension 3. |
Currently this function is restricted to rank 2, square shape, and dimension 3. |
846 |
* |
* |
847 |
*/ |
*/ |
848 |
|
ESCRIPT_DLL_API |
849 |
Data |
Data |
850 |
eigenvalues() const; |
eigenvalues() const; |
851 |
|
|
858 |
Currently this function is restricted to rank 2, square shape, and dimension 3 |
Currently this function is restricted to rank 2, square shape, and dimension 3 |
859 |
* |
* |
860 |
*/ |
*/ |
861 |
|
ESCRIPT_DLL_API |
862 |
const boost::python::tuple |
const boost::python::tuple |
863 |
eigenvalues_and_eigenvectors(const double tol=1.e-12) const; |
eigenvalues_and_eigenvectors(const double tol=1.e-12) const; |
864 |
|
|
865 |
/** |
/** |
866 |
\brief |
\brief |
867 |
Transpose each data point of this Data object around the given axis. |
swaps the components axis0 and axis1 |
|
--* not implemented yet *-- |
|
868 |
* |
* |
869 |
*/ |
*/ |
870 |
|
ESCRIPT_DLL_API |
871 |
Data |
Data |
872 |
transpose(int axis) const; |
swapaxes(const int axis0, const int axis1) const; |
873 |
|
|
874 |
/** |
/** |
875 |
\brief |
\brief |
876 |
Calculate the trace of each data point of this Data object. |
Return the error function erf of each data point of this Data object. |
877 |
* |
* |
878 |
*/ |
*/ |
879 |
|
ESCRIPT_DLL_API |
880 |
Data |
Data |
881 |
trace() const; |
erf() const; |
882 |
|
|
883 |
/** |
/** |
884 |
\brief |
\brief |
885 |
Return the sin of each data point of this Data object. |
Return the sin of each data point of this Data object. |
886 |
* |
* |
887 |
*/ |
*/ |
888 |
|
ESCRIPT_DLL_API |
889 |
Data |
Data |
890 |
sin() const; |
sin() const; |
891 |
|
|
894 |
Return the cos of each data point of this Data object. |
Return the cos of each data point of this Data object. |
895 |
* |
* |
896 |
*/ |
*/ |
897 |
|
ESCRIPT_DLL_API |
898 |
Data |
Data |
899 |
cos() const; |
cos() const; |
900 |
|
|
903 |
Return the tan of each data point of this Data object. |
Return the tan of each data point of this Data object. |
904 |
* |
* |
905 |
*/ |
*/ |
906 |
|
ESCRIPT_DLL_API |
907 |
Data |
Data |
908 |
tan() const; |
tan() const; |
909 |
|
|
912 |
Return the asin of each data point of this Data object. |
Return the asin of each data point of this Data object. |
913 |
* |
* |
914 |
*/ |
*/ |
915 |
|
ESCRIPT_DLL_API |
916 |
Data |
Data |
917 |
asin() const; |
asin() const; |
918 |
|
|
921 |
Return the acos of each data point of this Data object. |
Return the acos of each data point of this Data object. |
922 |
* |
* |
923 |
*/ |
*/ |
924 |
|
ESCRIPT_DLL_API |
925 |
Data |
Data |
926 |
acos() const; |
acos() const; |
927 |
|
|
930 |
Return the atan of each data point of this Data object. |
Return the atan of each data point of this Data object. |
931 |
* |
* |
932 |
*/ |
*/ |
933 |
|
ESCRIPT_DLL_API |
934 |
Data |
Data |
935 |
atan() const; |
atan() const; |
936 |
|
|
939 |
Return the sinh of each data point of this Data object. |
Return the sinh of each data point of this Data object. |
940 |
* |
* |
941 |
*/ |
*/ |
942 |
|
ESCRIPT_DLL_API |
943 |
Data |
Data |
944 |
sinh() const; |
sinh() const; |
945 |
|
|
948 |
Return the cosh of each data point of this Data object. |
Return the cosh of each data point of this Data object. |
949 |
* |
* |
950 |
*/ |
*/ |
951 |
|
ESCRIPT_DLL_API |
952 |
Data |
Data |
953 |
cosh() const; |
cosh() const; |
954 |
|
|
957 |
Return the tanh of each data point of this Data object. |
Return the tanh of each data point of this Data object. |
958 |
* |
* |
959 |
*/ |
*/ |
960 |
|
ESCRIPT_DLL_API |
961 |
Data |
Data |
962 |
tanh() const; |
tanh() const; |
963 |
|
|
966 |
Return the asinh of each data point of this Data object. |
Return the asinh of each data point of this Data object. |
967 |
* |
* |
968 |
*/ |
*/ |
969 |
|
ESCRIPT_DLL_API |
970 |
Data |
Data |
971 |
asinh() const; |
asinh() const; |
972 |
|
|
975 |
Return the acosh of each data point of this Data object. |
Return the acosh of each data point of this Data object. |
976 |
* |
* |
977 |
*/ |
*/ |
978 |
|
ESCRIPT_DLL_API |
979 |
Data |
Data |
980 |
acosh() const; |
acosh() const; |
981 |
|
|
984 |
Return the atanh of each data point of this Data object. |
Return the atanh of each data point of this Data object. |
985 |
* |
* |
986 |
*/ |
*/ |
987 |
|
ESCRIPT_DLL_API |
988 |
Data |
Data |
989 |
atanh() const; |
atanh() const; |
990 |
|
|
993 |
Return the log to base 10 of each data point of this Data object. |
Return the log to base 10 of each data point of this Data object. |
994 |
* |
* |
995 |
*/ |
*/ |
996 |
|
ESCRIPT_DLL_API |
997 |
Data |
Data |
998 |
log10() const; |
log10() const; |
999 |
|
|
1002 |
Return the natural log of each data point of this Data object. |
Return the natural log of each data point of this Data object. |
1003 |
* |
* |
1004 |
*/ |
*/ |
1005 |
|
ESCRIPT_DLL_API |
1006 |
Data |
Data |
1007 |
log() const; |
log() const; |
1008 |
|
|
1011 |
Return the exponential function of each data point of this Data object. |
Return the exponential function of each data point of this Data object. |
1012 |
* |
* |
1013 |
*/ |
*/ |
1014 |
|
ESCRIPT_DLL_API |
1015 |
Data |
Data |
1016 |
exp() const; |
exp() const; |
1017 |
|
|
1020 |
Return the square root of each data point of this Data object. |
Return the square root of each data point of this Data object. |
1021 |
* |
* |
1022 |
*/ |
*/ |
1023 |
|
ESCRIPT_DLL_API |
1024 |
Data |
Data |
1025 |
sqrt() const; |
sqrt() const; |
1026 |
|
|
1029 |
Return the negation of each data point of this Data object. |
Return the negation of each data point of this Data object. |
1030 |
* |
* |
1031 |
*/ |
*/ |
1032 |
|
ESCRIPT_DLL_API |
1033 |
Data |
Data |
1034 |
neg() const; |
neg() const; |
1035 |
|
|
1039 |
Simply returns this object unmodified. |
Simply returns this object unmodified. |
1040 |
* |
* |
1041 |
*/ |
*/ |
1042 |
|
ESCRIPT_DLL_API |
1043 |
Data |
Data |
1044 |
pos() const; |
pos() const; |
1045 |
|
|
1050 |
\param right Input - the power to raise the object to. |
\param right Input - the power to raise the object to. |
1051 |
* |
* |
1052 |
*/ |
*/ |
1053 |
|
ESCRIPT_DLL_API |
1054 |
Data |
Data |
1055 |
powD(const Data& right) const; |
powD(const Data& right) const; |
1056 |
|
|
1061 |
\param right Input - the power to raise the object to. |
\param right Input - the power to raise the object to. |
1062 |
* |
* |
1063 |
*/ |
*/ |
1064 |
|
ESCRIPT_DLL_API |
1065 |
Data |
Data |
1066 |
powO(const boost::python::object& right) const; |
powO(const boost::python::object& right) const; |
1067 |
|
|
1068 |
/** |
/** |
1069 |
\brief |
\brief |
1070 |
|
Return the given power of each data point of this boost python object. |
1071 |
|
|
1072 |
|
\param left Input - the bases |
1073 |
|
* |
1074 |
|
*/ |
1075 |
|
|
1076 |
|
ESCRIPT_DLL_API |
1077 |
|
Data |
1078 |
|
rpowO(const boost::python::object& left) const; |
1079 |
|
|
1080 |
|
/** |
1081 |
|
\brief |
1082 |
writes the object to a file in the DX file format |
writes the object to a file in the DX file format |
1083 |
*/ |
*/ |
1084 |
|
ESCRIPT_DLL_API |
1085 |
void |
void |
1086 |
saveDX(std::string fileName) const; |
saveDX(std::string fileName) const; |
1087 |
|
|
1089 |
\brief |
\brief |
1090 |
writes the object to a file in the VTK file format |
writes the object to a file in the VTK file format |
1091 |
*/ |
*/ |
1092 |
|
ESCRIPT_DLL_API |
1093 |
void |
void |
1094 |
saveVTK(std::string fileName) const; |
saveVTK(std::string fileName) const; |
1095 |
|
|
1099 |
\param right - Input - The right hand side. |
\param right - Input - The right hand side. |
1100 |
* |
* |
1101 |
*/ |
*/ |
1102 |
|
ESCRIPT_DLL_API |
1103 |
Data& operator+=(const Data& right); |
Data& operator+=(const Data& right); |
1104 |
|
ESCRIPT_DLL_API |
1105 |
Data& operator+=(const boost::python::object& right); |
Data& operator+=(const boost::python::object& right); |
1106 |
|
|
1107 |
/** |
/** |
1110 |
\param right - Input - The right hand side. |
\param right - Input - The right hand side. |
1111 |
* |
* |
1112 |
*/ |
*/ |
1113 |
|
ESCRIPT_DLL_API |
1114 |
Data& operator-=(const Data& right); |
Data& operator-=(const Data& right); |
1115 |
|
ESCRIPT_DLL_API |
1116 |
Data& operator-=(const boost::python::object& right); |
Data& operator-=(const boost::python::object& right); |
1117 |
|
|
1118 |
/** |
/** |
1121 |
\param right - Input - The right hand side. |
\param right - Input - The right hand side. |
1122 |
* |
* |
1123 |
*/ |
*/ |
1124 |
|
ESCRIPT_DLL_API |
1125 |
Data& operator*=(const Data& right); |
Data& operator*=(const Data& right); |
1126 |
|
ESCRIPT_DLL_API |
1127 |
Data& operator*=(const boost::python::object& right); |
Data& operator*=(const boost::python::object& right); |
1128 |
|
|
1129 |
/** |
/** |
1132 |
\param right - Input - The right hand side. |
\param right - Input - The right hand side. |
1133 |
* |
* |
1134 |
*/ |
*/ |
1135 |
|
ESCRIPT_DLL_API |
1136 |
Data& operator/=(const Data& right); |
Data& operator/=(const Data& right); |
1137 |
|
ESCRIPT_DLL_API |
1138 |
Data& operator/=(const boost::python::object& right); |
Data& operator/=(const boost::python::object& right); |
1139 |
|
|
1140 |
/** |
/** |
1141 |
\brief |
\brief |
1142 |
Returns true if this can be interpolated to functionspace. |
Returns true if this can be interpolated to functionspace. |
1143 |
*/ |
*/ |
1144 |
|
ESCRIPT_DLL_API |
1145 |
bool |
bool |
1146 |
probeInterpolation(const FunctionSpace& functionspace) const; |
probeInterpolation(const FunctionSpace& functionspace) const; |
1147 |
|
|
1160 |
\param key - Input - python slice tuple specifying |
\param key - Input - python slice tuple specifying |
1161 |
slice to return. |
slice to return. |
1162 |
*/ |
*/ |
1163 |
|
ESCRIPT_DLL_API |
1164 |
Data |
Data |
1165 |
getItem(const boost::python::object& key) const; |
getItem(const boost::python::object& key) const; |
1166 |
|
|
1175 |
slice to copy from value. |
slice to copy from value. |
1176 |
\param value - Input - Data object to copy from. |
\param value - Input - Data object to copy from. |
1177 |
*/ |
*/ |
1178 |
|
ESCRIPT_DLL_API |
1179 |
void |
void |
1180 |
setItemD(const boost::python::object& key, |
setItemD(const boost::python::object& key, |
1181 |
const Data& value); |
const Data& value); |
1182 |
|
|
1183 |
|
ESCRIPT_DLL_API |
1184 |
void |
void |
1185 |
setItemO(const boost::python::object& key, |
setItemO(const boost::python::object& key, |
1186 |
const boost::python::object& value); |
const boost::python::object& value); |
1193 |
this Data object. |
this Data object. |
1194 |
*/ |
*/ |
1195 |
template <class UnaryFunction> |
template <class UnaryFunction> |
1196 |
|
ESCRIPT_DLL_API |
1197 |
inline |
inline |
1198 |
void |
void |
1199 |
unaryOp(UnaryFunction operation); |
unaryOp(UnaryFunction operation); |
1205 |
\param region - Input - Region to copy. |
\param region - Input - Region to copy. |
1206 |
* |
* |
1207 |
*/ |
*/ |
1208 |
|
ESCRIPT_DLL_API |
1209 |
Data |
Data |
1210 |
getSlice(const DataArrayView::RegionType& region) const; |
getSlice(const DataArrayView::RegionType& region) const; |
1211 |
|
|
1217 |
\param region - Input - Region to copy. |
\param region - Input - Region to copy. |
1218 |
* |
* |
1219 |
*/ |
*/ |
1220 |
|
ESCRIPT_DLL_API |
1221 |
void |
void |
1222 |
setSlice(const Data& value, |
setSlice(const Data& value, |
1223 |
const DataArrayView::RegionType& region); |
const DataArrayView::RegionType& region); |
1227 |
Archive the current Data object to the given file. |
Archive the current Data object to the given file. |
1228 |
\param fileName - Input - file to archive to. |
\param fileName - Input - file to archive to. |
1229 |
*/ |
*/ |
1230 |
|
ESCRIPT_DLL_API |
1231 |
void |
void |
1232 |
archiveData(const std::string fileName); |
archiveData(const std::string fileName); |
1233 |
|
|
1239 |
\param fileName - Input - file to extract from. |
\param fileName - Input - file to extract from. |
1240 |
\param fspace - Input - a suitable FunctionSpace descibing the data. |
\param fspace - Input - a suitable FunctionSpace descibing the data. |
1241 |
*/ |
*/ |
1242 |
|
ESCRIPT_DLL_API |
1243 |
void |
void |
1244 |
extractData(const std::string fileName, |
extractData(const std::string fileName, |
1245 |
const FunctionSpace& fspace); |
const FunctionSpace& fspace); |
1246 |
|
|
1247 |
|
|
1248 |
|
/** |
1249 |
|
\brief |
1250 |
|
print the data values to stdout. Used for debugging |
1251 |
|
*/ |
1252 |
|
ESCRIPT_DLL_API |
1253 |
|
void |
1254 |
|
print(void); |
1255 |
|
|
1256 |
|
/** |
1257 |
|
\brief |
1258 |
|
return the MPI rank number of the local data |
1259 |
|
MPI_COMM_WORLD is assumed and the result of MPI_Comm_size() |
1260 |
|
is returned |
1261 |
|
*/ |
1262 |
|
ESCRIPT_DLL_API |
1263 |
|
int |
1264 |
|
get_MPIRank(void) const; |
1265 |
|
|
1266 |
|
/** |
1267 |
|
\brief |
1268 |
|
return the MPI rank number of the local data |
1269 |
|
MPI_COMM_WORLD is assumed and the result of MPI_Comm_rank() |
1270 |
|
is returned |
1271 |
|
*/ |
1272 |
|
ESCRIPT_DLL_API |
1273 |
|
int |
1274 |
|
get_MPISize(void) const; |
1275 |
|
|
1276 |
|
/** |
1277 |
|
\brief |
1278 |
|
return the MPI rank number of the local data |
1279 |
|
MPI_COMM_WORLD is assumed and returned. |
1280 |
|
*/ |
1281 |
|
ESCRIPT_DLL_API |
1282 |
|
MPI_Comm |
1283 |
|
get_MPIComm(void) const; |
1284 |
|
|
1285 |
|
/** |
1286 |
|
\brief |
1287 |
|
return the object produced by the factory, which is a DataConstant or DataExpanded |
1288 |
|
*/ |
1289 |
|
ESCRIPT_DLL_API |
1290 |
|
DataAbstract* |
1291 |
|
borrowData(void) const; |
1292 |
|
|
1293 |
protected: |
protected: |
1294 |
|
|
1295 |
private: |
private: |
1347 |
|
|
1348 |
/** |
/** |
1349 |
\brief |
\brief |
|
Perform the given binary operation on all of the data's elements. |
|
|
RHS is a boost::python object. |
|
|
*/ |
|
|
template <class BinaryFunction> |
|
|
inline |
|
|
void |
|
|
binaryOp(const boost::python::object& right, |
|
|
BinaryFunction operation); |
|
|
|
|
|
/** |
|
|
\brief |
|
1350 |
Convert the data type of the RHS to match this. |
Convert the data type of the RHS to match this. |
1351 |
\param right - Input - data type to match. |
\param right - Input - data type to match. |
1352 |
*/ |
*/ |
1371 |
const FunctionSpace& what, |
const FunctionSpace& what, |
1372 |
bool expanded); |
bool expanded); |
1373 |
|
|
1374 |
/** |
// |
1375 |
\brief |
// flag to protect the data object against any update |
1376 |
Reshape the data point if the data point is currently rank 0. |
bool m_protected; |
|
Will throw an exception if the data points are not rank 0. |
|
|
The original data point value is used for all values of the new |
|
|
data point. |
|
|
*/ |
|
|
void |
|
|
reshapeDataPoint(const DataArrayView::ShapeType& shape); |
|
1377 |
|
|
1378 |
// |
// |
1379 |
// pointer to the actual data object |
// pointer to the actual data object |
1410 |
/** |
/** |
1411 |
Binary Data object operators. |
Binary Data object operators. |
1412 |
*/ |
*/ |
1413 |
|
inline double rpow(double x,double y) |
1414 |
|
{ |
1415 |
|
return pow(y,x); |
1416 |
|
}; |
1417 |
|
|
1418 |
/** |
/** |
1419 |
\brief |
\brief |
1420 |
Operator+ |
Operator+ |
1421 |
Takes two Data objects. |
Takes two Data objects. |
1422 |
*/ |
*/ |
1423 |
Data operator+(const Data& left, const Data& right); |
ESCRIPT_DLL_API Data operator+(const Data& left, const Data& right); |
1424 |
|
|
1425 |
/** |
/** |
1426 |
\brief |
\brief |
1427 |
Operator- |
Operator- |
1428 |
Takes two Data objects. |
Takes two Data objects. |
1429 |
*/ |
*/ |
1430 |
Data operator-(const Data& left, const Data& right); |
ESCRIPT_DLL_API Data operator-(const Data& left, const Data& right); |
1431 |
|
|
1432 |
/** |
/** |
1433 |
\brief |
\brief |
1434 |
Operator* |
Operator* |
1435 |
Takes two Data objects. |
Takes two Data objects. |
1436 |
*/ |
*/ |
1437 |
Data operator*(const Data& left, const Data& right); |
ESCRIPT_DLL_API Data operator*(const Data& left, const Data& right); |
1438 |
|
|
1439 |
/** |
/** |
1440 |
\brief |
\brief |
1441 |
Operator/ |
Operator/ |
1442 |
Takes two Data objects. |
Takes two Data objects. |
1443 |
*/ |
*/ |
1444 |
Data operator/(const Data& left, const Data& right); |
ESCRIPT_DLL_API Data operator/(const Data& left, const Data& right); |
1445 |
|
|
1446 |
/** |
/** |
1447 |
\brief |
\brief |
1449 |
Takes LHS Data object and RHS python::object. |
Takes LHS Data object and RHS python::object. |
1450 |
python::object must be convertable to Data type. |
python::object must be convertable to Data type. |
1451 |
*/ |
*/ |
1452 |
Data operator+(const Data& left, const boost::python::object& right); |
ESCRIPT_DLL_API Data operator+(const Data& left, const boost::python::object& right); |
1453 |
|
|
1454 |
/** |
/** |
1455 |
\brief |
\brief |
1457 |
Takes LHS Data object and RHS python::object. |
Takes LHS Data object and RHS python::object. |
1458 |
python::object must be convertable to Data type. |
python::object must be convertable to Data type. |
1459 |
*/ |
*/ |
1460 |
Data operator-(const Data& left, const boost::python::object& right); |
ESCRIPT_DLL_API Data operator-(const Data& left, const boost::python::object& right); |
1461 |
|
|
1462 |
/** |
/** |
1463 |
\brief |
\brief |
1465 |
Takes LHS Data object and RHS python::object. |
Takes LHS Data object and RHS python::object. |
1466 |
python::object must be convertable to Data type. |
python::object must be convertable to Data type. |
1467 |
*/ |
*/ |
1468 |
Data operator*(const Data& left, const boost::python::object& right); |
ESCRIPT_DLL_API Data operator*(const Data& left, const boost::python::object& right); |
1469 |
|
|
1470 |
/** |
/** |
1471 |
\brief |
\brief |
1473 |
Takes LHS Data object and RHS python::object. |
Takes LHS Data object and RHS python::object. |
1474 |
python::object must be convertable to Data type. |
python::object must be convertable to Data type. |
1475 |
*/ |
*/ |
1476 |
Data operator/(const Data& left, const boost::python::object& right); |
ESCRIPT_DLL_API Data operator/(const Data& left, const boost::python::object& right); |
1477 |
|
|
1478 |
/** |
/** |
1479 |
\brief |
\brief |
1481 |
Takes LHS python::object and RHS Data object. |
Takes LHS python::object and RHS Data object. |
1482 |
python::object must be convertable to Data type. |
python::object must be convertable to Data type. |
1483 |
*/ |
*/ |
1484 |
Data operator+(const boost::python::object& left, const Data& right); |
ESCRIPT_DLL_API Data operator+(const boost::python::object& left, const Data& right); |
1485 |
|
|
1486 |
/** |
/** |
1487 |
\brief |
\brief |
1489 |
Takes LHS python::object and RHS Data object. |
Takes LHS python::object and RHS Data object. |
1490 |
python::object must be convertable to Data type. |
python::object must be convertable to Data type. |
1491 |
*/ |
*/ |
1492 |
Data operator-(const boost::python::object& left, const Data& right); |
ESCRIPT_DLL_API Data operator-(const boost::python::object& left, const Data& right); |
1493 |
|
|
1494 |
/** |
/** |
1495 |
\brief |
\brief |
1497 |
Takes LHS python::object and RHS Data object. |
Takes LHS python::object and RHS Data object. |
1498 |
python::object must be convertable to Data type. |
python::object must be convertable to Data type. |
1499 |
*/ |
*/ |
1500 |
Data operator*(const boost::python::object& left, const Data& right); |
ESCRIPT_DLL_API Data operator*(const boost::python::object& left, const Data& right); |
1501 |
|
|
1502 |
/** |
/** |
1503 |
\brief |
\brief |
1505 |
Takes LHS python::object and RHS Data object. |
Takes LHS python::object and RHS Data object. |
1506 |
python::object must be convertable to Data type. |
python::object must be convertable to Data type. |
1507 |
*/ |
*/ |
1508 |
Data operator/(const boost::python::object& left, const Data& right); |
ESCRIPT_DLL_API Data operator/(const boost::python::object& left, const Data& right); |
1509 |
|
|
1510 |
/** |
/** |
1511 |
\brief |
\brief |
1512 |
Output operator |
Output operator |
1513 |
*/ |
*/ |
1514 |
std::ostream& operator<<(std::ostream& o, const Data& data); |
ESCRIPT_DLL_API std::ostream& operator<<(std::ostream& o, const Data& data); |
1515 |
|
|
1516 |
|
/** |
1517 |
|
\brief |
1518 |
|
Compute a tensor product of two Data objects |
1519 |
|
\param arg0 - Input - Data object |
1520 |
|
\param arg1 - Input - Data object |
1521 |
|
\param axis_offset - Input - axis offset |
1522 |
|
\param transpose - Input - 0: transpose neither, 1: transpose arg0, 2: transpose arg1 |
1523 |
|
*/ |
1524 |
|
ESCRIPT_DLL_API |
1525 |
|
Data |
1526 |
|
C_GeneralTensorProduct(Data& arg0, |
1527 |
|
Data& arg1, |
1528 |
|
int axis_offset=0, |
1529 |
|
int transpose=0); |
1530 |
|
|
1531 |
/** |
/** |
1532 |
\brief |
\brief |
1534 |
NB: this operator does very little at this point, and isn't to |
NB: this operator does very little at this point, and isn't to |
1535 |
be relied on. Requires further implementation. |
be relied on. Requires further implementation. |
1536 |
*/ |
*/ |
1537 |
//bool operator==(const Data& left, const Data& right); |
//ESCRIPT_DLL_API bool operator==(const Data& left, const Data& right); |
1538 |
|
|
1539 |
/** |
/** |
1540 |
\brief |
\brief |
1550 |
// |
// |
1551 |
// if this has a rank of zero promote it to the rank of the RHS |
// if this has a rank of zero promote it to the rank of the RHS |
1552 |
if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) { |
if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) { |
1553 |
reshapeDataPoint(right.getPointDataView().getShape()); |
throw DataException("Error - attempt to update rank zero object with object with rank bigger than zero."); |
1554 |
} |
} |
1555 |
// |
// |
1556 |
// initially make the temporary a shallow copy |
// initially make the temporary a shallow copy |
1602 |
EsysAssert((leftC!=0 && rightC!=0), "Programming error - casting to DataConstant."); |
EsysAssert((leftC!=0 && rightC!=0), "Programming error - casting to DataConstant."); |
1603 |
escript::binaryOp(*leftC,*rightC,operation); |
escript::binaryOp(*leftC,*rightC,operation); |
1604 |
} |
} |
1605 |
} |
#if defined DOPROF |
1606 |
|
profData->binary++; |
1607 |
/** |
#endif |
|
\brief |
|
|
Perform the given binary operation with this and right as operands. |
|
|
Right is a boost::python object. |
|
|
*/ |
|
|
template <class BinaryFunction> |
|
|
inline |
|
|
void |
|
|
Data::binaryOp(const boost::python::object& right, |
|
|
BinaryFunction operation) |
|
|
{ |
|
|
DataArray temp(right); |
|
|
// |
|
|
// if this has a rank of zero promote it to the rank of the RHS. |
|
|
if (getPointDataView().getRank()==0 && temp.getView().getRank()!=0) { |
|
|
reshapeDataPoint(temp.getView().getShape()); |
|
|
} |
|
|
// |
|
|
// Always allow scalar values for the RHS but check other shapes |
|
|
if (temp.getView().getRank()!=0) { |
|
|
if (!getPointDataView().checkShape(temp.getView().getShape())) { |
|
|
throw DataException(getPointDataView().createShapeErrorMessage( |
|
|
"Error - RHS shape doesn't match LHS shape.",temp.getView().getShape())); |
|
|
} |
|
|
} |
|
|
if (isExpanded()) { |
|
|
DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get()); |
|
|
EsysAssert((leftC!=0),"Programming error - casting to DataExpanded."); |
|
|
escript::binaryOp(*leftC,temp.getView(),operation); |
|
|
} else if (isTagged()) { |
|
|
DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get()); |
|
|
EsysAssert((leftC!=0), "Programming error - casting to DataTagged."); |
|
|
escript::binaryOp(*leftC,temp.getView(),operation); |
|
|
} else if (isConstant()) { |
|
|
DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get()); |
|
|
EsysAssert((leftC!=0),"Programming error - casting to DataConstant."); |
|
|
escript::binaryOp(*leftC,temp.getView(),operation); |
|
|
} |
|
1608 |
} |
} |
1609 |
|
|
1610 |
/** |
/** |