escript Revision_
Data.h
Go to the documentation of this file.
1
2/*****************************************************************************
3*
4* Copyright (c) 2003-2020 by The University of Queensland
5* http://www.uq.edu.au
6*
7* Primary Business: Queensland, Australia
8* Licensed under the Apache License, version 2.0
9* http://www.apache.org/licenses/LICENSE-2.0
10*
11* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12* Development 2012-2013 by School of Earth Sciences
13* Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
14* Development from 2019 by School of Earth and Environmental Sciences
15**
16*****************************************************************************/
17
20#ifndef __ESCRIPT_DATA_H__
21#define __ESCRIPT_DATA_H__
22
23#include "system_dep.h"
24#include "DataAbstract.h"
25#include "DataException.h"
26#include "DataTypes.h"
27#include "EsysMPI.h"
28#include "FunctionSpace.h"
29#include "DataVectorOps.h"
30#include <algorithm>
31#include <string>
32#include <sstream>
33
34#include <boost/python/object.hpp>
35#include <boost/python/tuple.hpp>
36#include <boost/math/special_functions/bessel.hpp>
37
38#ifndef ESCRIPT_MAX_DATA_RANK
39#define ESCRIPT_MAX_DATA_RANK 4
40#endif
41
42namespace escript {
43
44//
45// Forward declaration for various implementations of Data.
46class DataConstant;
47class DataTagged;
48class DataExpanded;
49class DataLazy;
50
65
66 public:
67
77 Data();
78
84 Data(const Data& inData);
85
92 Data(const Data& inData,
93 const FunctionSpace& what);
94
99 const DataTypes::ShapeType& shape,
100 const FunctionSpace& what,
101 bool expanded);
102
115 const DataTypes::ShapeType& dataPointShape,
116 const FunctionSpace& what,
117 bool expanded);
118
130 explicit
132 const DataTypes::ShapeType& dataPointShape,
133 const FunctionSpace& what,
134 bool expanded);
135
143 Data(const Data& inData,
144 const DataTypes::RegionType& region);
145
146
157 Data(const WrappedArray& w, const FunctionSpace& what,
158 bool expanded);
159
160
170 Data(const boost::python::object& value,
171 const Data& other);
172
193 Data(boost::python::object value,
194 boost::python::object par1=boost::python::object(),
195 boost::python::object par2=boost::python::object(),
196 boost::python::object par3=boost::python::object());
197
198
199
200
201
206 explicit Data(DataAbstract* underlyingdata);
207
211 explicit Data(DataAbstract_ptr underlyingdata);
212
217 ~Data();
218
222 void
223 copy(const Data& other);
224
228 Data
229 copySelf() const;
230
231
235 Data
236 delay();
237
241 void
242 delaySelf();
243
244
254 void
255 setProtection();
256
262 bool
263 isProtected() const;
264
265
270 const boost::python::object
271 getValueOfDataPointAsTuple(int dataPointNo);
272
277 void
278 setValueOfDataPointToPyObject(int dataPointNo, const boost::python::object& py_object);
279
284 void
285 setValueOfDataPointToArray(int dataPointNo, const boost::python::object&);
286
291 void
292 setValueOfDataPoint(int dataPointNo, const DataTypes::real_t);
293
294 void
295 setValueOfDataPointC(int dataPointNo, const DataTypes::cplx_t);
296
297
301 const boost::python::object
302 getValueOfGlobalDataPointAsTuple(int procNo, int dataPointNo);
303
304
308 void
309 setTupleForGlobalDataPoint(int id, int proc, boost::python::object);
310
316 int
317 getTagNumber(int dpno);
318
319
324 std::string
325 toString() const;
326
331 void
332 expand();
333
340 void
341 tag();
342
347 void
348 resolve();
349
355 bool
356 hasNaN();
357
361 void
362 replaceNaN(DataTypes::real_t value);
363
367 void
368 replaceNaN(DataTypes::cplx_t value);
369
373 void
374 replaceNaNPython(boost::python::object obj);
375
376 bool
377 hasInf();
378
379 void
380 replaceInf(DataTypes::real_t value);
381
382 void
383 replaceInf(DataTypes::cplx_t value);
384
385 void
386 replaceInfPython(boost::python::object obj);
387
388
396 void
397 requireWrite();
398
404 bool
405 isExpanded() const;
406
412 bool
413 actsExpanded() const;
414
415
420 bool
421 isTagged() const;
422
427 bool
428 isConstant() const;
429
433 bool
434 isLazy() const;
435
439 bool
440 isReady() const;
441
447 bool
448 isEmpty() const;
449
454 bool
455 isComplex() const;
456
461 inline
462 const FunctionSpace&
464 {
465 return m_data->getFunctionSpace();
466 }
467
472 inline
475 {
476 // This is exposed to Python as [Data object].getX()
477 return m_data->getFunctionSpace().getX();
478 }
479
484 inline
485// const AbstractDomain&
487 getDomain() const
488 {
489 return getFunctionSpace().getDomain();
490 }
491
492
498 inline
499// const AbstractDomain&
502 {
503 return getFunctionSpace().getDomainPython();
504 }
505
510 inline
511 unsigned int
513 {
514 return m_data->getRank();
515 }
516
521 inline
522 int
524 {
525 return getNumSamples() * getNumDataPointsPerSample();
526 }
531 inline
532 int
534 {
535 return m_data->getNumSamples();
536 }
537
542 inline
543 int
545 {
546 return m_data->getNumDPPSample();
547 }
548
554 inline
555 bool numSamplesEqual(int numDataPointsPerSample, int numSamples) const
556 {
557 return (isEmpty() ||
558 (numDataPointsPerSample==getNumDataPointsPerSample() && numSamples==getNumSamples()));
559 }
560
566 inline
567 bool isDataPointShapeEqual(int rank, const int* dimensions) const
568 {
569 if (isEmpty())
570 return true;
571 const DataTypes::ShapeType givenShape(&dimensions[0],&dimensions[rank]);
572 return (getDataPointShape()==givenShape);
573 }
574
579 int
581 {
582 return m_data->getNoValues();
583 }
584
585
590 void
591 dump(const std::string fileName) const;
592
599 const boost::python::object
600 toListOfTuples(bool scalarastuple=true);
601
602
610 const DataTypes::real_t*
611 getSampleDataRO(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0) const;
612
613 const DataTypes::cplx_t*
614 getSampleDataRO(DataTypes::CplxVectorType::size_type sampleNo, DataTypes::cplx_t dummy) const;
615
616
625 getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0);
626
628 getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::cplx_t dummy);
629
630
631
638 const DataTypes::real_t*
639 getDataRO(DataTypes::real_t dummy=0) const;
640
641 const DataTypes::cplx_t*
642 getDataRO(DataTypes::cplx_t dummy) const;
643
644
645
652 inline
655 {
656 return m_data->getSampleDataByTag(tag, dummy);
657 }
658
659 inline
662 {
663 return m_data->getSampleDataByTag(tag, dummy);
664 }
665
666
674 getDataPointRO(int sampleNo, int dataPointNo);
675
683 getDataPointRW(int sampleNo, int dataPointNo);
684
685
686
691 inline
693 getDataOffset(int sampleNo,
694 int dataPointNo)
695 {
696 return m_data->getPointOffset(sampleNo,dataPointNo);
697 }
698
703 inline
706 {
707 return m_data->getShape();
708 }
709
714 const boost::python::tuple
715 getShapeTuple() const;
716
721 long
722 getShapeProduct() const;
723
724
730 int
731 getDataPointSize() const;
732
738 getLength() const;
739
744 bool
746 {
747 return m_data->getNumSamples()==0;
748 }
749
758 void
759 setTaggedValueByName(std::string name,
760 const boost::python::object& value);
761
771 void
772 setTaggedValue(int tagKey,
773 const boost::python::object& value);
774
785 void
786 setTaggedValueFromCPP(int tagKey,
787 const DataTypes::ShapeType& pointshape,
788 const DataTypes::RealVectorType& value,
789 int dataOffset=0);
790
791
792 void
793 setTaggedValueFromCPP(int tagKey,
794 const DataTypes::ShapeType& pointshape,
795 const DataTypes::CplxVectorType& value,
796 int dataOffset=0);
797
802 void
803 copyWithMask(const Data& other,
804 const Data& mask);
805
815 void
816 setToZero();
817
824 Data
825 interpolate(const FunctionSpace& functionspace) const;
826
827 Data
828 interpolateFromTable3D(const WrappedArray& table, DataTypes::real_t Amin, DataTypes::real_t Astep,
830 DataTypes::real_t Cmin, DataTypes::real_t Cstep, bool check_boundaries);
831
832 Data
833 interpolateFromTable2D(const WrappedArray& table, DataTypes::real_t Amin, DataTypes::real_t Astep,
834 DataTypes::real_t undef, Data& B, DataTypes::real_t Bmin, DataTypes::real_t Bstep,bool check_boundaries);
835
836 Data
837 interpolateFromTable1D(const WrappedArray& table, DataTypes::real_t Amin, DataTypes::real_t Astep,
838 DataTypes::real_t undef,bool check_boundaries);
839
840
841 Data
842 interpolateFromTable3DP(boost::python::object table, DataTypes::real_t Amin, DataTypes::real_t Astep,
843 Data& B, DataTypes::real_t Bmin, DataTypes::real_t Bstep, Data& C, DataTypes::real_t Cmin, DataTypes::real_t Cstep, DataTypes::real_t undef,bool check_boundaries);
844
845
846 Data
847 interpolateFromTable2DP(boost::python::object table, DataTypes::real_t Amin, DataTypes::real_t Astep,
848 Data& B, DataTypes::real_t Bmin, DataTypes::real_t Bstep, DataTypes::real_t undef,bool check_boundaries);
849
850 Data
851 interpolateFromTable1DP(boost::python::object table, DataTypes::real_t Amin, DataTypes::real_t Astep,
852 DataTypes::real_t undef,bool check_boundaries);
853
854 Data
855 nonuniforminterp(boost::python::object in, boost::python::object out, bool check_boundaries);
856
857 Data
858 nonuniformslope(boost::python::object in, boost::python::object out, bool check_boundaries);
859
866 Data
867 gradOn(const FunctionSpace& functionspace) const;
868
869 Data
870 grad() const;
871
876 boost::python::object
877 integrateToTuple_const() const;
878
879
884 boost::python::object
885 integrateToTuple();
886
887
888
894 Data
895 oneOver() const;
901 Data
902 wherePositive() const;
903
909 Data
910 whereNegative() const;
911
917 Data
918 whereNonNegative() const;
919
925 Data
926 whereNonPositive() const;
927
933 Data
934 whereZero(DataTypes::real_t tol=0.0) const;
935
941 Data
942 whereNonZero(DataTypes::real_t tol=0.0) const;
943
956 Lsup();
957
959 Lsup_const() const;
960
961
974 sup();
975
977 sup_const() const;
978
979
992 inf();
993
995 inf_const() const;
996
997
998
1004 Data
1005 abs() const;
1006
1012 Data
1013 phase() const;
1014
1015
1021 Data
1022 maxval() const;
1023
1029 Data
1030 minval() const;
1031
1039 const boost::python::tuple
1040 minGlobalDataPoint() const;
1041
1049 const boost::python::tuple
1050 maxGlobalDataPoint() const;
1051
1052
1053
1060 Data
1061 sign() const;
1062
1068 Data
1069 symmetric() const;
1070
1076 Data
1077 antisymmetric() const;
1078
1079
1085 Data
1086 hermitian() const;
1087
1093 Data
1094 antihermitian() const;
1095
1101 Data
1102 trace(int axis_offset) const;
1103
1109 Data
1110 transpose(int axis_offset) const;
1111
1118 Data
1119 eigenvalues() const;
1120
1130 const boost::python::tuple
1131 eigenvalues_and_eigenvectors(const DataTypes::real_t tol=1.e-12) const;
1132
1138 Data
1139 swapaxes(const int axis0, const int axis1) const;
1140
1146 Data
1147 erf() const;
1148
1149
1155 Data
1156 conjugate() const;
1157
1158 Data
1159 real() const;
1160
1161 Data
1162 imag() const;
1163
1169 Data
1170 sin() const;
1171
1177 Data
1178 cos() const;
1179
1185 Data
1186 bessel(int order, DataTypes::real_t (*besselfunc) (int,DataTypes::real_t) );
1187
1188
1194 Data
1195 besselFirstKind(int order);
1196
1202 Data
1203 besselSecondKind(int order);
1204
1205
1211 Data
1212 tan() const;
1213
1219 Data
1220 asin() const;
1221
1227 Data
1228 acos() const;
1229
1235 Data
1236 atan() const;
1237
1243 Data
1244 sinh() const;
1245
1251 Data
1252 cosh() const;
1253
1259 Data
1260 tanh() const;
1261
1267 Data
1268 asinh() const;
1269
1275 Data
1276 acosh() const;
1277
1283 Data
1284 atanh() const;
1285
1291 Data
1292 log10() const;
1293
1299 Data
1300 log() const;
1301
1307 Data
1308 exp() const;
1309
1315 Data
1316 sqrt() const;
1317
1323 Data
1324 neg() const;
1325
1332 Data
1333 pos() const;
1334
1342 Data
1343 powD(const Data& right) const;
1344
1352 Data
1353 powO(const boost::python::object& right) const;
1354
1363 Data
1364 rpowO(const boost::python::object& left) const;
1365
1372 Data& operator+=(const Data& right);
1373 Data& operator+=(const boost::python::object& right);
1374
1375 Data& operator=(const Data& other);
1376
1383 Data& operator-=(const Data& right);
1384 Data& operator-=(const boost::python::object& right);
1385
1392 Data& operator*=(const Data& right);
1393 Data& operator*=(const boost::python::object& right);
1394
1401 Data& operator/=(const Data& right);
1402 Data& operator/=(const boost::python::object& right);
1403
1408 Data truedivD(const Data& right);
1409
1414 Data truedivO(const boost::python::object& right);
1415
1420 Data rtruedivO(const boost::python::object& left);
1421
1426 boost::python::object __add__(const boost::python::object& right);
1427
1428
1433 boost::python::object __sub__(const boost::python::object& right);
1434
1439 boost::python::object __rsub__(const boost::python::object& right);
1440
1445 boost::python::object __mul__(const boost::python::object& right);
1446
1451 boost::python::object __div__(const boost::python::object& right);
1452
1457 boost::python::object __rdiv__(const boost::python::object& right);
1458
1462 Data
1463 matrixInverse() const;
1464
1469 bool
1470 probeInterpolation(const FunctionSpace& functionspace) const;
1471
1487 Data
1488 getItem(const boost::python::object& key) const;
1489
1501 void
1502 setItemD(const boost::python::object& key,
1503 const Data& value);
1504
1505 void
1506 setItemO(const boost::python::object& key,
1507 const boost::python::object& value);
1508
1509 // These following public methods should be treated as private.
1510
1516 template <class UnaryFunction>
1517 inline
1518 void
1519 unaryOp2(UnaryFunction operation);
1520
1528 Data
1529 getSlice(const DataTypes::RegionType& region) const;
1530
1539 void
1540 setSlice(const Data& value,
1541 const DataTypes::RegionType& region);
1542
1547 void
1548 print(void);
1549
1556 int
1557 get_MPIRank(void) const;
1558
1565 int
1566 get_MPISize(void) const;
1567
1573 MPI_Comm
1574 get_MPIComm(void) const;
1575
1582 borrowData(void) const;
1583
1585 borrowDataPtr(void) const;
1586
1588 borrowReadyPtr(void) const;
1589
1590
1591
1600 getDataAtOffsetRO(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy);
1601
1603 getDataAtOffsetRW(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy);
1604
1606 getDataAtOffsetRO(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy);
1607
1609 getDataAtOffsetRW(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy);
1610
1611
1622 getExpandedVectorReference(DataTypes::real_t dummy=0);
1623
1625 getExpandedVectorReference(DataTypes::cplx_t dummy);
1626
1627
1632 size_t
1633 getNumberOfTaggedValues() const;
1634
1635 /*
1636 * \brief make the data complex
1637 */
1638 void complicate();
1639
1640 protected:
1641
1642 private:
1643 void init_from_data_and_fs(const Data& inData,
1644 const FunctionSpace& functionspace);
1645
1646 template <typename S>
1647 void
1648 maskWorker(Data& other2, Data& mask2, S sentinel);
1649
1650 template <class BinaryOp>
1652#ifdef ESYS_MPI
1653 lazyAlgWorker(DataTypes::real_t init, MPI_Op mpiop_type);
1654#else
1656#endif
1657
1659 LsupWorker() const;
1660
1662 supWorker() const;
1663
1665 infWorker() const;
1666
1667 template<typename Scalar>
1668 boost::python::object
1670
1671 void
1672 calc_minGlobalDataPoint(int& ProcNo, int& DataPointNo) const;
1673
1674 void
1675 calc_maxGlobalDataPoint(int& ProcNo, int& DataPointNo) const;
1676
1677 // For internal use in Data.cpp only!
1678 // other uses should call the main entry points and allow laziness
1679 Data
1680 minval_nonlazy() const;
1681
1682 // For internal use in Data.cpp only!
1683 Data
1684 maxval_nonlazy() const;
1685
1686
1693 inline
1694 void
1695 operandCheck(const Data& right) const
1696 {
1697 return m_data->operandCheck(*(right.m_data.get()));
1698 }
1699
1705 template <class BinaryFunction>
1706 inline
1708 reduction(BinaryFunction operation,
1709 DataTypes::real_t initial_value) const;
1710
1718 template <class BinaryFunction>
1719 inline
1720 Data
1721 dp_algorithm(BinaryFunction operation,
1722 DataTypes::real_t initial_value) const;
1723
1729 void
1730 typeMatchLeft(Data& right) const;
1731
1737 void
1738 typeMatchRight(const Data& right);
1739
1745 void
1746 initialise(const DataTypes::RealVectorType& value,
1747 const DataTypes::ShapeType& shape,
1748 const FunctionSpace& what,
1749 bool expanded);
1750
1751 void
1752 initialise(const DataTypes::CplxVectorType& value,
1753 const DataTypes::ShapeType& shape,
1754 const FunctionSpace& what,
1755 bool expanded);
1756
1757 void
1758 initialise(const WrappedArray& value,
1759 const FunctionSpace& what,
1760 bool expanded);
1761
1762 void
1763 initialise(const DataTypes::real_t value,
1764 const DataTypes::ShapeType& shape,
1765 const FunctionSpace& what,
1766 bool expanded);
1767
1768 void
1769 initialise(const DataTypes::cplx_t value,
1770 const DataTypes::ShapeType& shape,
1771 const FunctionSpace& what,
1772 bool expanded);
1773 //
1774 // flag to protect the data object against any update
1777
1778 //
1779 // pointer to the actual data object
1780// boost::shared_ptr<DataAbstract> m_data;
1782
1783// If possible please use getReadyPtr instead.
1784// But see warning below.
1785 const DataReady*
1786 getReady() const
1787{
1788 const DataReady* dr=dynamic_cast<const DataReady*>(m_data.get());
1789 ESYS_ASSERT(dr!=0, "error casting to DataReady.");
1790 return dr;
1791}
1792
1793 DataReady*
1795{
1796 DataReady* dr=dynamic_cast<DataReady*>(m_data.get());
1797 ESYS_ASSERT(dr!=0, "error casting to DataReady.");
1798 return dr;
1799}
1800
1801
1802// Be wary of using this for local operations since it (temporarily) increases reference count.
1803// If you are just using this to call a method on DataReady instead of DataAbstract consider using
1804// getReady() instead
1807{
1808 DataReady_ptr dr=REFCOUNTNS::dynamic_pointer_cast<DataReady>(m_data);
1809 ESYS_ASSERT(dr.get()!=0, "error casting to DataReady.");
1810 return dr;
1811}
1812
1815{
1816 const_DataReady_ptr dr=REFCOUNTNS::dynamic_pointer_cast<const DataReady>(m_data);
1817 ESYS_ASSERT(dr.get()!=0, "error casting to DataReady.");
1818 return dr;
1819}
1820
1821 // In the isShared() method below:
1822 // A problem would occur if m_data (the address pointed to) were being modified
1823 // while the call m_data->is_shared is being executed.
1824 //
1825 // Q: So why do I think this code can be thread safe/correct?
1826 // A: We need to make some assumptions.
1827 // 1. We assume it is acceptable to return true under some conditions when we aren't shared.
1828 // 2. We assume that no constructions or assignments which will share previously unshared
1829 // will occur while this call is executing. This is consistent with the way Data:: and C are written.
1830 //
1831 // This means that the only transition we need to consider, is when a previously shared object is
1832 // not shared anymore. ie. the other objects have been destroyed or a deep copy has been made.
1833 // In those cases the m_shared flag changes to false after m_data has completed changing.
1834 // For any threads executing before the flag switches they will assume the object is still shared.
1835 bool isShared() const
1836 {
1837#ifdef SLOWSHARECHECK
1838 return m_data->isShared(); // single threadsafe check for this
1839#else
1840 return !m_data.unique();
1841#endif
1842 }
1843
1845 {
1846 if (isLazy())
1847 {
1848 #ifdef _OPENMP
1849 if (omp_in_parallel())
1850 { // Yes this is throwing an exception out of an omp thread which is forbidden.
1851 throw DataException("Please do not call forceResolve() in a parallel region.");
1852 }
1853 #endif
1854 resolve();
1855 }
1856 }
1857
1863 {
1864#ifdef _OPENMP
1865 if (omp_in_parallel())
1866 {
1867 throw DataException("Programming error. Please do not run exclusiveWrite() in multi-threaded sections.");
1868 }
1869#endif
1870 forceResolve();
1871 if (isShared())
1872 {
1873 DataAbstract* t=m_data->deepCopy();
1874 set_m_data(DataAbstract_ptr(t));
1875 }
1876#ifdef EXWRITECHK
1877 m_data->exclusivewritecalled=true;
1878#endif
1879 }
1880
1885 {
1886 if (isLazy() || isShared())
1887 {
1888 std::ostringstream oss;
1889 oss << "Programming error. ExclusiveWrite required - please call requireWrite() isLazy=" << isLazy() << " isShared()=" << isShared();
1890 throw DataException(oss.str());
1891 }
1892 }
1893
1900 void set_m_data(DataAbstract_ptr p);
1901
1902
1903 void TensorSelfUpdateBinaryOperation(const Data& right, escript::ES_optype operation);
1904
1905 friend class DataAbstract; // To allow calls to updateShareStatus
1906 friend class TestDomain; // so its getX will work quickly
1907#ifdef IKNOWWHATIMDOING
1908 friend Data applyBinaryCFunction(boost::python::object cfunc, boost::python::tuple shape, escript::Data& d, escript::Data& e);
1909#endif
1910 template <typename S>
1911 friend Data condEvalWorker(escript::Data& mask, escript::Data& trueval, escript::Data& falseval, S sentinel);
1912 friend ESCRIPT_DLL_API Data randomData(const boost::python::tuple& shape, const FunctionSpace& what, long seed, const boost::python::tuple& filter);
1913
1914};
1915
1916
1917#ifdef IKNOWWHATIMDOING
1918Data
1919applyBinaryCFunction(boost::python::object func, boost::python::tuple shape, escript::Data& d, escript::Data& e);
1920#endif
1921
1923Data
1924condEval(escript::Data& mask, escript::Data& trueval, escript::Data& falseval);
1925
1926
1927
1932Data randomData(const boost::python::tuple& shape,
1933 const FunctionSpace& what,
1934 long seed, const boost::python::tuple& filter);
1935
1936
1937} // end namespace escript
1938
1939
1940// No, this is not supposed to be at the top of the file
1941// DataAbstact needs to be declared first, then DataReady needs to be fully declared
1942// so that I can dynamic cast between them below.
1943#include "DataReady.h"
1944#include "DataLazy.h"
1945#include "DataExpanded.h"
1946#include "DataConstant.h"
1947#include "DataTagged.h"
1948
1949namespace escript
1950{
1951
1952
1953
1954inline
1957{
1958 if (isLazy())
1959 {
1960 throw DataException("Error, attempt to acquire RW access to lazy data. Please call requireWrite() first.");
1961 }
1962#ifdef EXWRITECHK
1963 if (!getReady()->exclusivewritecalled)
1964 {
1965 throw DataException("Error, call to Data::getSampleDataRW without a preceeding call to requireWrite/exclusiveWrite.");
1966 }
1967#endif
1968 return getReady()->getSampleDataRW(sampleNo, dummy);
1969}
1970
1971inline
1974{
1975 if (isLazy())
1976 {
1977 throw DataException("Error, attempt to acquire RW access to lazy data. Please call requireWrite() first.");
1978 }
1979#ifdef EXWRITECHK
1980 if (!getReady()->exclusivewritecalled)
1981 {
1982 throw DataException("Error, call to Data::getSampleDataRW without a preceeding call to requireWrite/exclusiveWrite.");
1983 }
1984#endif
1985 return getReady()->getSampleDataRW(sampleNo, dummy);
1986}
1987
1988
1989inline
1990const DataTypes::real_t*
1992{
1993 DataLazy* l=dynamic_cast<DataLazy*>(m_data.get());
1994 if (l!=0)
1995 {
1996 size_t offset=0;
1997 const DataTypes::RealVectorType* res=l->resolveSample(sampleNo,offset);
1998 return &((*res)[offset]);
1999 }
2000 return getReady()->getSampleDataRO(sampleNo, dummy);
2001}
2002
2003inline
2004const DataTypes::cplx_t*
2006{
2007 DataLazy* l=dynamic_cast<DataLazy*>(m_data.get());
2008 if (l!=0)
2009 {
2010 throw DataException("Programming error: complex lazy objects are not supported.");
2011 }
2012 return getReady()->getSampleDataRO(sampleNo, dummy);
2013}
2014
2015
2016inline
2017const DataTypes::real_t*
2019{
2020 if (isLazy())
2021 {
2022 throw DataException("Programmer error - getDataRO must not be called on Lazy Data.");
2023 }
2024 if (getNumSamples()==0)
2025 {
2026 return 0;
2027 }
2028 else
2029 {
2030 return &(getReady()->getTypedVectorRO(0)[0]);
2031 }
2032}
2033
2034inline
2035const DataTypes::cplx_t*
2037{
2038 if (isLazy())
2039 {
2040 throw DataException("Programmer error - getDataRO must not be called on Lazy Data.");
2041 }
2042 if (getNumSamples()==0)
2043 {
2044 return 0;
2045 }
2046 else
2047 {
2048 return &(getReady()->getTypedVectorRO(dummy)[0]);
2049 }
2050}
2051
2052
2057{
2058 return pow(y,x);
2059}
2060
2067Data operator+(const Data& left, const Data& right);
2068
2075Data operator-(const Data& left, const Data& right);
2076
2083Data operator*(const Data& left, const Data& right);
2084
2091Data operator/(const Data& left, const Data& right);
2092
2100Data operator+(const Data& left, const boost::python::object& right);
2101
2109Data operator-(const Data& left, const boost::python::object& right);
2110
2118Data operator*(const Data& left, const boost::python::object& right);
2119
2127Data operator/(const Data& left, const boost::python::object& right);
2128
2136Data operator+(const boost::python::object& left, const Data& right);
2137
2145Data operator-(const boost::python::object& left, const Data& right);
2146
2154Data operator*(const boost::python::object& left, const Data& right);
2155
2163Data operator/(const boost::python::object& left, const Data& right);
2164
2165
2166
2172std::ostream& operator<<(std::ostream& o, const Data& data);
2173
2183Data
2184C_GeneralTensorProduct(Data& arg_0,
2185 Data& arg_1,
2186 int axis_offset=0,
2187 int transpose=0);
2188
2194inline
2195Data
2197{
2198 return *this / right;
2199}
2200
2206inline
2207Data
2208Data::truedivO(const boost::python::object& right)
2209{
2210 Data tmp(right, getFunctionSpace(), false);
2211 return truedivD(tmp);
2212}
2213
2219inline
2220Data
2221Data::rtruedivO(const boost::python::object& left)
2222{
2223 Data tmp(left, getFunctionSpace(), false);
2224 return tmp.truedivD(*this);
2225}
2226
2227
2228
2236template <class BinaryFunction>
2237inline
2239Data::reduction(BinaryFunction operation, DataTypes::real_t initial_value) const
2240{
2241 if (isExpanded()) {
2242 DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());
2243 ESYS_ASSERT(leftC!=0, "Programming error - casting to DataExpanded.");
2244
2245 DataExpanded& data=*leftC;
2246 int i,j;
2247 int numDPPSample=data.getNumDPPSample();
2248 int numSamples=data.getNumSamples();
2249 DataTypes::real_t global_current_value=initial_value;
2250 DataTypes::real_t local_current_value;
2251 const auto& vec=data.getTypedVectorRO(typename BinaryFunction::first_argument_type(0));
2252 const DataTypes::ShapeType& shape=data.getShape();
2253 // calculate the reduction operation value for each data point
2254 // reducing the result for each data-point into the current_value variables
2255 #pragma omp parallel private(local_current_value)
2256 {
2257 local_current_value=initial_value;
2258 #pragma omp for private(i,j) schedule(static)
2259 for (i=0;i<numSamples;i++) {
2260 for (j=0;j<numDPPSample;j++) {
2261 local_current_value=operation(local_current_value,escript::reductionOpVector(vec,shape,data.getPointOffset(i,j),operation,initial_value));
2262
2263 }
2264 }
2265 #pragma omp critical
2266 global_current_value=operation(global_current_value,local_current_value);
2267 }
2268 return global_current_value;
2269 } else if (isTagged()) {
2270 DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());
2271 ESYS_ASSERT(leftC!=0, "Programming error - casting to DataTagged.");
2272
2273 DataTagged& data=*leftC;
2274 DataTypes::real_t current_value=initial_value;
2275
2276 const auto& vec=data.getTypedVectorRO(typename BinaryFunction::first_argument_type(0));
2277 const DataTypes::ShapeType& shape=data.getShape();
2278 const DataTagged::DataMapType& lookup=data.getTagLookup();
2279 const std::list<int> used=data.getFunctionSpace().getListOfTagsSTL();
2280 for (std::list<int>::const_iterator i=used.begin();i!=used.end();++i)
2281 {
2282 int tag=*i;
2283 DataTagged::DataMapType::const_iterator it=lookup.find(tag);
2284 if ((tag==0) || (it==lookup.end())) // check for the default tag
2285 {
2286 current_value=operation(current_value,escript::reductionOpVector(vec,shape,data.getDefaultOffset(),operation,initial_value));
2287 }
2288 else
2289 {
2290 current_value=operation(current_value,escript::reductionOpVector(vec,shape,it->second,operation,initial_value));
2291 }
2292 }
2293 return current_value;
2294 } else if (isConstant()) {
2295 DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());
2296 ESYS_ASSERT(leftC!=0, "Programming error - casting to DataConstant.");
2297 return escript::reductionOpVector(leftC->getTypedVectorRO(typename BinaryFunction::first_argument_type(0)),leftC->getShape(),0,operation,initial_value);
2298 } else if (isEmpty()) {
2299 throw DataException("Error - Operations (algorithm) not permitted on instances of DataEmpty.");
2300 } else if (isLazy()) {
2301 throw DataException("Error - Operations not permitted on instances of DataLazy.");
2302 } else {
2303 throw DataException("Error - Data encapsulates an unknown type.");
2304 }
2305}
2306
2315template <class BinaryFunction>
2316inline
2317Data
2318Data::dp_algorithm(BinaryFunction operation, DataTypes::real_t initial_value) const
2319{
2320 if (isEmpty()) {
2321 throw DataException("Error - Operations (dp_algorithm) not permitted on instances of DataEmpty.");
2322 }
2323 else if (isExpanded()) {
2325 DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
2326 DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
2327 ESYS_ASSERT(dataE!=0, "Programming error - casting data to DataExpanded.");
2328 ESYS_ASSERT(resultE!=0, "Programming error - casting result to DataExpanded.");
2329
2330
2331
2332 int i,j;
2333 int numSamples=dataE->getNumSamples();
2334 int numDPPSample=dataE->getNumDPPSample();
2335 // DataArrayView dataView=data.getPointDataView();
2336 // DataArrayView resultView=result.getPointDataView();
2337 const auto& dataVec=dataE->getTypedVectorRO(initial_value);
2338 const DataTypes::ShapeType& shape=dataE->getShape();
2339 auto& resultVec=resultE->getTypedVectorRW(initial_value);
2340 // perform the operation on each data-point and assign
2341 // this to the corresponding element in result
2342 #pragma omp parallel for private(i,j) schedule(static)
2343 for (i=0;i<numSamples;i++) {
2344 for (j=0;j<numDPPSample;j++) {
2345 resultVec[resultE->getPointOffset(i,j)] =
2346 escript::reductionOpVector(dataVec, shape, dataE->getPointOffset(i,j),operation,initial_value);
2347
2348 }
2349 }
2350 //escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
2351 return result;
2352 }
2353 else if (isTagged()) {
2354 DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
2355 ESYS_ASSERT(dataT!=0, "Programming error - casting data to DataTagged.");
2356 DataTypes::RealVectorType defval(1);
2357 defval[0]=0;
2358 DataTagged* resultT=new DataTagged(getFunctionSpace(), DataTypes::scalarShape, defval, dataT);
2359
2360
2361 const DataTypes::ShapeType& shape=dataT->getShape();
2362 const auto& vec=dataT->getTypedVectorRO(initial_value);
2363 const DataTagged::DataMapType& lookup=dataT->getTagLookup();
2364 for (DataTagged::DataMapType::const_iterator i=lookup.begin(); i!=lookup.end(); i++) {
2365 resultT->getDataByTagRW(i->first,0) =
2366 escript::reductionOpVector(vec,shape,dataT->getOffsetForTag(i->first),operation,initial_value);
2367 }
2368 resultT->getTypedVectorRW(initial_value)[resultT->getDefaultOffset()] = escript::reductionOpVector(dataT->getTypedVectorRO(initial_value),dataT->getShape(),dataT->getDefaultOffset(),operation,initial_value);
2369
2370
2371
2372
2373 //escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
2374 return Data(resultT); // note: the Data object now owns the resultT pointer
2375 }
2376 else if (isConstant()) {
2378 DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
2379 DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
2380 ESYS_ASSERT(dataC!=0, "Programming error - casting data to DataConstant.");
2381 ESYS_ASSERT(resultC!=0, "Programming error - casting result to DataConstant.");
2382
2383 DataConstant& data=*dataC;
2384 resultC->getTypedVectorRW(initial_value)[0] =
2385 escript::reductionOpVector(data.getTypedVectorRO(initial_value),data.getShape(),0,operation,initial_value);
2386
2387 //escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
2388 return result;
2389 } else if (isLazy()) {
2390 throw DataException("Error - Operations not permitted on instances of DataLazy.");
2391 } else {
2392 throw DataException("Error - Data encapsulates an unknown type.");
2393 }
2394}
2395
2396
2404Data
2405C_TensorBinaryOperation(Data const &arg_0,
2406 Data const &arg_1,
2407 ES_optype operation);
2408
2409
2410Data
2411C_TensorUnaryOperation(Data const &arg_0,
2412 escript::ES_optype operation,
2413 DataTypes::real_t tol=0);
2414
2415} // namespace escript
2416
2417#endif // __ESCRIPT_DATA_H__
#define ESYS_ASSERT(a, b)
EsysAssert is a MACRO that will throw an exception if the boolean condition specified is false.
Definition Assert.h:79
Describes binary operations performed on DataVector.
int MPI_Op
Definition EsysMPI.h:46
int MPI_Comm
Definition EsysMPI.h:44
#define S(_J_, _I_)
Definition ShapeFunctions.cpp:122
Definition DataAbstract.h:63
int getNumDPPSample() const
Return the number of data points per sample.
Definition DataAbstract.h:612
const DataTypes::ShapeType & getShape() const
Return the shape information for the point data.
Definition DataAbstract.h:642
int getNumSamples() const
Return the number of samples.
Definition DataAbstract.h:623
virtual DataAbstract * deepCopy() const =0
Return a deep copy of the current object.
const FunctionSpace & getFunctionSpace() const
Return the function space associated with this Data object.
Definition DataAbstract.h:635
DataConstant stores a single data point which represents the entire function space.
Definition DataConstant.h:38
virtual DataTypes::RealVectorType & getTypedVectorRW(DataTypes::real_t dummy)
These versions use the type system rather than method name to determine return type.
Definition DataConstant.cpp:865
virtual const DataTypes::RealVectorType & getTypedVectorRO(DataTypes::real_t dummy) const
Definition DataConstant.cpp:872
Definition DataException.h:28
Give a short description of what DataExpanded does.
Definition DataExpanded.h:44
virtual DataTypes::RealVectorType::size_type getPointOffset(int sampleNo, int dataPointNo) const
Return the offset for the given given data point. This returns the offset in bytes for the given poin...
Definition DataExpanded.cpp:622
virtual const DataTypes::RealVectorType & getTypedVectorRO(DataTypes::real_t dummy) const
Definition DataExpanded.cpp:1532
virtual DataTypes::RealVectorType & getTypedVectorRW(DataTypes::real_t dummy)
These versions use the type system rather than method name to determine return type.
Definition DataExpanded.cpp:1526
Wraps an expression tree of other DataObjects. The data will be evaluated when required.
const DataTypes::RealVectorType * resolveSample(int sampleNo, size_t &roffset) const
Compute the value of the expression for the given sample.
Definition DataLazy.cpp:2336
Definition DataReady.h:37
const DataTypes::real_t * getSampleDataRO(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0) const
Definition DataReady.h:218
DataTypes::real_t * getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0)
Return the sample data for the given sample number.
Definition DataReady.h:204
virtual const DataTypes::RealVectorType & getTypedVectorRO(DataTypes::real_t dummy) const =0
Simulates a full dataset accessible via sampleNo and dataPointNo.
Definition DataTagged.h:46
std::map< int, int > DataMapType
Definition DataTagged.h:58
virtual DataTypes::RealVectorType & getTypedVectorRW(DataTypes::real_t dummy)
These versions use the type system rather than method name to determine return type.
Definition DataTagged.cpp:1669
DataTypes::RealVectorType::size_type getDefaultOffset() const
Returns the offset in the structure which stores the default value.
Definition DataTagged.h:724
DataTypes::RealVectorType::size_type getOffsetForTag(int tag) const
getOffsetForTag
Definition DataTagged.cpp:995
const DataMapType & getTagLookup() const
getTagLookup
Definition DataTagged.h:762
DataTypes::RealVectorType::reference getDataByTagRW(int tag, DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0)
getDataByTag
Definition DataTagged.cpp:1017
virtual const DataTypes::RealVectorType & getTypedVectorRO(DataTypes::real_t dummy) const
Definition DataTagged.cpp:1676
ElementType & reference
Definition DataVectorAlt.h:51
DataTypes::vec_size_type size_type
Definition DataVectorAlt.h:50
const ElementType & const_reference
Definition DataVectorAlt.h:52
Data represents a collection of datapoints.
Definition Data.h:64
bool m_lazy
Definition Data.h:1776
friend Data condEvalWorker(escript::Data &mask, escript::Data &trueval, escript::Data &falseval, S sentinel)
bool hasNoSamples() const
Return true if this object contains no samples. This is not the same as isEmpty()
Definition Data.h:745
Data dp_algorithm(BinaryFunction operation, DataTypes::real_t initial_value) const
Reduce each data-point in this Data object using the given operation. Return a Data object with the s...
Definition Data.h:2318
Domain_ptr getDomainPython() const
Return the domain. TODO: For internal use only. This should be removed.
Definition Data.h:501
DataAbstract_ptr m_data
Definition Data.h:1781
DataTypes::real_t * getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0)
Return the sample data for the given sample no. Please do not use this unless you NEED to access samp...
Definition Data.h:1956
DataTypes::real_t reduction(BinaryFunction operation, DataTypes::real_t initial_value) const
Perform the specified reduction algorithm on every element of every data point in this Data object ac...
Definition Data.h:2239
DataTypes::CplxVectorType::const_reference getDataAtOffsetRO(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy)
const DataTypes::real_t * getSampleDataRO(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0) const
Return the sample data for the given sample no. Please do not use this unless you NEED to access samp...
Definition Data.h:1991
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition Data.h:463
void tag()
If possible convert this Data to DataTagged. This will only allow Constant data to be converted to ta...
Definition Data.cpp:1204
DataTypes::cplx_t * getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::cplx_t dummy)
DataTypes::cplx_t * getSampleDataByTag(int tag, DataTypes::cplx_t dummy)
Definition Data.h:661
bool isDataPointShapeEqual(int rank, const int *dimensions) const
Returns true if the shape matches the vector (dimensions[0],..., dimensions[rank-1])....
Definition Data.h:567
Data truedivD(const Data &right)
Newer style division operator for python.
Definition Data.h:2196
DataTypes::CplxVectorType::reference getDataAtOffsetRW(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy)
void exclusiveWrite()
if another object is sharing out member data make a copy to work with instead. This code should only ...
Definition Data.h:1862
DataReady_ptr getReadyPtr()
Definition Data.h:1806
int getNumSamples() const
Return the number of samples.
Definition Data.h:533
const DataTypes::ShapeType & getDataPointShape() const
Return a reference to the data point shape.
Definition Data.h:705
int getNumDataPoints() const
Return the number of data points.
Definition Data.h:523
DataTypes::real_t * getSampleDataByTag(int tag, DataTypes::real_t dummy=0)
Return the sample data for the given tag. If an attempt is made to access data that isn't tagged an e...
Definition Data.h:654
boost::python::object integrateWorker() const
int getNoValues() const
Return the number of values in the shape for this object.
Definition Data.h:580
void checkExclusiveWrite()
checks if caller can have exclusive write to the object
Definition Data.h:1884
int getNumDataPointsPerSample() const
Return the number of data points per sample.
Definition Data.h:544
bool isConstant() const
Return true if this Data is constant.
Definition Data.cpp:1139
void forceResolve()
Definition Data.h:1844
Data truedivO(const boost::python::object &right)
Newer style division operator for python.
Definition Data.h:2208
const_Domain_ptr getDomain() const
Return the domain.
Definition Data.h:487
escript::Data getXFromFunctionSpace() const
Returns the spatial locations of the data points.
Definition Data.h:474
bool isTagged() const
Return true if this Data is tagged.
Definition Data.cpp:1125
bool m_protected
Definition Data.h:1775
bool isExpanded() const
Return true if this Data is expanded.
Definition Data.cpp:1111
bool isLazy() const
Return true if this Data is lazy.
Definition Data.cpp:1146
void unaryOp2(UnaryFunction operation)
Perform the given unary operation on every element of every data point in this Data object.
bool isEmpty() const
Definition Data.cpp:1132
const DataReady * getReady() const
Definition Data.h:1786
unsigned int getDataPointRank() const
Return the rank of the point data.
Definition Data.h:512
const_DataReady_ptr getReadyPtr() const
Definition Data.h:1814
DataTypes::real_t lazyAlgWorker(DataTypes::real_t init)
bool numSamplesEqual(int numDataPointsPerSample, int numSamples) const
Returns true if the number of data points per sample and the number of samples match the respective a...
Definition Data.h:555
Data rtruedivO(const boost::python::object &left)
Newer style division operator for python.
Definition Data.h:2221
void operandCheck(const Data &right) const
Check *this and the right operand are compatible. Throws an exception if they aren't.
Definition Data.h:1695
bool isShared() const
Definition Data.h:1835
const DataTypes::cplx_t * getSampleDataRO(DataTypes::CplxVectorType::size_type sampleNo, DataTypes::cplx_t dummy) const
Data()
Default constructor. Creates a DataEmpty object.
Definition Data.cpp:246
friend Data randomData(const boost::python::tuple &shape, const FunctionSpace &what, long seed, const boost::python::tuple &filter)
Create a new Expanded Data object filled with pseudo-random data.
DataTypes::RealVectorType::size_type getDataOffset(int sampleNo, int dataPointNo)
Return the offset for the given sample and point within the sample.
Definition Data.h:693
const DataTypes::real_t * getDataRO(DataTypes::real_t dummy=0) const
Return a pointer to the beginning of the underlying data.
Definition Data.h:2018
DataReady * getReady()
Definition Data.h:1794
Definition FunctionSpace.h:36
escript::Data getX() const
Returns the spatial locations of the data points.
Definition FunctionSpace.cpp:229
std::list< int > getListOfTagsSTL() const
Returns an stl list of the tags used in this function space.
Definition FunctionSpace.cpp:335
(Testing use only) Provides a domain to wrap a collection of values.
Definition TestDomain.h:43
Definition WrappedArray.h:33
#define ESCRIPT_DLL_API
Definition escriptcore/src/system_dep.h:30
std::complex< real_t > cplx_t
complex data type
Definition DataTypes.h:55
std::vector< std::pair< int, int > > RegionType
Definition DataTypes.h:45
double real_t
type of all real-valued scalars in escript
Definition DataTypes.h:52
static const ShapeType scalarShape
Use this instead of creating empty shape objects for scalars.
Definition DataTypes.h:48
std::vector< int > ShapeType
The shape of a single datapoint.
Definition DataTypes.h:44
Definition AbstractContinuousDomain.cpp:23
std::ostream & operator<<(std::ostream &o, const Data &data)
Output operator.
Definition Data.cpp:3679
DataTypes::real_t reductionOpVector(const DataTypes::RealVectorType &left, const DataTypes::ShapeType &leftShape, DataTypes::RealVectorType::size_type offset, BinaryFunction operation, DataTypes::real_t initial_value)
Perform the given data point reduction operation on the data point specified by the given offset into...
Definition DataVectorOps.h:1397
void eigenvalues_and_eigenvectors(const DataTypes::RealVectorType &in, const DataTypes::ShapeType &inShape, DataTypes::RealVectorType::size_type inOffset, DataTypes::RealVectorType &ev, const DataTypes::ShapeType &evShape, DataTypes::RealVectorType::size_type evOffset, DataTypes::RealVectorType &V, const DataTypes::ShapeType &VShape, DataTypes::RealVectorType::size_type VOffset, const double tol=1.e-13)
solves a local eigenvalue problem
Definition DataVectorOps.h:750
Data C_GeneralTensorProduct(Data &arg_0, Data &arg_1, int axis_offset=0, int transpose=0)
Compute a tensor product of two Data objects.
Definition Data.cpp:3686
Data operator*(const AbstractSystemMatrix &left, const Data &right)
Definition AbstractSystemMatrix.cpp:60
void eigenvalues(const DataTypes::RealVectorType &in, const DataTypes::ShapeType &inShape, typename DataTypes::RealVectorType::size_type inOffset, DataTypes::RealVectorType &ev, const DataTypes::ShapeType &evShape, typename DataTypes::RealVectorType::size_type evOffset)
solves a local eigenvalue problem
Definition DataVectorOps.h:639
void symmetric(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset)
computes a symmetric matrix from your square matrix A: (A + transpose(A)) / 2
Definition DataVectorOps.h:103
void swapaxes(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset, int axis0, int axis1)
swaps the components axis0 and axis1.
Definition DataVectorOps.h:488
T1 conjugate(const T2 i)
Definition ArrayOps.h:734
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition AbstractDomain.h:43
void transpose(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset, int axis_offset)
Transpose each data point of this Data object around the given axis.
Definition DataVectorOps.h:343
Data operator/(const Data &left, const Data &right)
Operator/ Takes two Data objects.
Definition Data.cpp:3374
Data condEval(escript::Data &mask, escript::Data &trueval, escript::Data &falseval)
Definition Data.cpp:5644
void antisymmetric(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset)
computes a antisymmetric matrix from your square matrix A: (A - transpose(A)) / 2
Definition DataVectorOps.h:152
boost::shared_ptr< DataAbstract > DataAbstract_ptr
Definition DataAbstract.h:54
Data operator-(const Data &left, const Data &right)
Operator- Takes two Data objects.
Definition Data.cpp:3355
DataTypes::real_t rpow(DataTypes::real_t x, DataTypes::real_t y)
Definition Data.h:2056
Data randomData(const boost::python::tuple &shape, const FunctionSpace &what, long seed, const boost::python::tuple &filter)
Create a new Expanded Data object filled with pseudo-random data.
Definition Data.cpp:5868
void antihermitian(const DataTypes::CplxVectorType &in, const DataTypes::ShapeType &inShape, typename DataTypes::CplxVectorType::size_type inOffset, DataTypes::CplxVectorType &ev, const DataTypes::ShapeType &evShape, typename DataTypes::CplxVectorType::size_type evOffset)
computes a antihermitian matrix from your square matrix A: (A - adjoint(A)) / 2
Definition DataVectorOps.cpp:963
Data C_TensorBinaryOperation(Data const &arg_0, Data const &arg_1, ES_optype operation)
Compute a tensor operation with two Data objects.
Definition Data.cpp:6351
boost::shared_ptr< const AbstractDomain > const_Domain_ptr
Definition AbstractDomain.h:44
Data operator+(const Data &left, const Data &right)
Operator+ Takes two Data objects.
Definition Data.cpp:3345
ES_optype
Definition ES_optype.h:30
void trace(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset, int axis_offset)
computes the trace of a matrix
Definition DataVectorOps.h:242
Data C_TensorUnaryOperation(Data const &arg_0, escript::ES_optype operation, DataTypes::real_t tol=0)
Definition Data.cpp:6075
boost::shared_ptr< DataReady > DataReady_ptr
Definition DataAbstract.h:59
boost::shared_ptr< const DataReady > const_DataReady_ptr
Definition DataAbstract.h:60
void hermitian(const DataTypes::CplxVectorType &in, const DataTypes::ShapeType &inShape, DataTypes::CplxVectorType::size_type inOffset, DataTypes::CplxVectorType &ev, const DataTypes::ShapeType &evShape, DataTypes::CplxVectorType::size_type evOffset)
computes an hermitian matrix from your square matrix A: (A + adjoint(A)) / 2
Definition DataVectorOps.cpp:916