47 |
// ensure the current object is not a DataLazy |
// ensure the current object is not a DataLazy |
48 |
// The idea was that we could add an optional warning whenever a resolve is forced |
// The idea was that we could add an optional warning whenever a resolve is forced |
49 |
#define FORCERESOLVE if (isLazy()) {resolve();} |
#define FORCERESOLVE if (isLazy()) {resolve();} |
50 |
|
#define AUTOLAZYON escriptParams.getAUTOLAZY() |
51 |
|
#define MAKELAZYOP(X) if (isLazy() || (AUTOLAZYON && m_data->isExpanded())) \ |
52 |
|
{\ |
53 |
|
DataLazy* c=new DataLazy(borrowDataPtr(),X);\ |
54 |
|
return Data(c);\ |
55 |
|
} |
56 |
|
#define MAKELAZYOPOFF(X,Y) if (isLazy() || (AUTOLAZYON && m_data->isExpanded())) \ |
57 |
|
{\ |
58 |
|
DataLazy* c=new DataLazy(borrowDataPtr(),X,Y);\ |
59 |
|
return Data(c);\ |
60 |
|
} |
61 |
|
|
62 |
|
#define MAKELAZYBINSELF(R,X) if (isLazy() || R.isLazy() || (AUTOLAZYON && (isExpanded() || R.isExpanded()))) \ |
63 |
|
{\ |
64 |
|
DataLazy* c=new DataLazy(m_data,R.borrowDataPtr(),X);\ |
65 |
|
m_data=c->getPtr();\ |
66 |
|
return (*this);\ |
67 |
|
} |
68 |
|
|
69 |
|
// like the above but returns a new data rather than *this |
70 |
|
#define MAKELAZYBIN(R,X) if (isLazy() || R.isLazy() || (AUTOLAZYON && (isExpanded() || R.isExpanded()))) \ |
71 |
|
{\ |
72 |
|
DataLazy* c=new DataLazy(m_data,R.borrowDataPtr(),X);\ |
73 |
|
return Data(c);\ |
74 |
|
} |
75 |
|
|
76 |
|
#define MAKELAZYBIN2(L,R,X) if (L.isLazy() || R.isLazy() || (AUTOLAZYON && (L.isExpanded() || R.isExpanded()))) \ |
77 |
|
{\ |
78 |
|
DataLazy* c=new DataLazy(L.borrowDataPtr(),R.borrowDataPtr(),X);\ |
79 |
|
return Data(c);\ |
80 |
|
} |
81 |
|
|
82 |
Data::Data() |
Data::Data() |
83 |
{ |
{ |
694 |
Data |
Data |
695 |
Data::oneOver() const |
Data::oneOver() const |
696 |
{ |
{ |
697 |
if (isLazy()) |
MAKELAZYOP(RECIP) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),RECIP); |
|
|
return Data(c); |
|
|
} |
|
698 |
return C_TensorUnaryOperation(*this, bind1st(divides<double>(),1.)); |
return C_TensorUnaryOperation(*this, bind1st(divides<double>(),1.)); |
699 |
} |
} |
700 |
|
|
701 |
Data |
Data |
702 |
Data::wherePositive() const |
Data::wherePositive() const |
703 |
{ |
{ |
704 |
if (isLazy()) |
MAKELAZYOP(GZ) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),GZ); |
|
|
return Data(c); |
|
|
} |
|
705 |
return C_TensorUnaryOperation(*this, bind2nd(greater<double>(),0.0)); |
return C_TensorUnaryOperation(*this, bind2nd(greater<double>(),0.0)); |
706 |
} |
} |
707 |
|
|
708 |
Data |
Data |
709 |
Data::whereNegative() const |
Data::whereNegative() const |
710 |
{ |
{ |
711 |
if (isLazy()) |
MAKELAZYOP(LZ) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),LZ); |
|
|
return Data(c); |
|
|
} |
|
712 |
return C_TensorUnaryOperation(*this, bind2nd(less<double>(),0.0)); |
return C_TensorUnaryOperation(*this, bind2nd(less<double>(),0.0)); |
713 |
} |
} |
714 |
|
|
715 |
Data |
Data |
716 |
Data::whereNonNegative() const |
Data::whereNonNegative() const |
717 |
{ |
{ |
718 |
if (isLazy()) |
MAKELAZYOP(GEZ) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),GEZ); |
|
|
return Data(c); |
|
|
} |
|
719 |
return C_TensorUnaryOperation(*this, bind2nd(greater_equal<double>(),0.0)); |
return C_TensorUnaryOperation(*this, bind2nd(greater_equal<double>(),0.0)); |
720 |
} |
} |
721 |
|
|
722 |
Data |
Data |
723 |
Data::whereNonPositive() const |
Data::whereNonPositive() const |
724 |
{ |
{ |
725 |
if (isLazy()) |
MAKELAZYOP(LEZ) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),LEZ); |
|
|
return Data(c); |
|
|
} |
|
726 |
return C_TensorUnaryOperation(*this, bind2nd(less_equal<double>(),0.0)); |
return C_TensorUnaryOperation(*this, bind2nd(less_equal<double>(),0.0)); |
727 |
} |
} |
728 |
|
|
750 |
Data::probeInterpolation(const FunctionSpace& functionspace) const |
Data::probeInterpolation(const FunctionSpace& functionspace) const |
751 |
{ |
{ |
752 |
return getFunctionSpace().probeInterpolation(functionspace); |
return getFunctionSpace().probeInterpolation(functionspace); |
|
// if (getFunctionSpace()==functionspace) { |
|
|
// return true; |
|
|
// } else { |
|
|
// const_Domain_ptr domain=getDomain(); |
|
|
// if (*domain==*functionspace.getDomain()) { |
|
|
// return domain->probeInterpolationOnDomain(getFunctionSpace().getTypeCode(),functionspace.getTypeCode()); |
|
|
// } else { |
|
|
// return domain->probeInterpolationACross(getFunctionSpace().getTypeCode(),*(functionspace.getDomain()),functionspace.getTypeCode()); |
|
|
// } |
|
|
// } |
|
753 |
} |
} |
754 |
|
|
755 |
Data |
Data |
884 |
// |
// |
885 |
// return the array |
// return the array |
886 |
return numArray; |
return numArray; |
|
|
|
887 |
} |
} |
888 |
|
|
889 |
void |
void |
1200 |
Data |
Data |
1201 |
Data::sin() const |
Data::sin() const |
1202 |
{ |
{ |
1203 |
if (isLazy()) |
MAKELAZYOP(SIN) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),SIN); |
|
|
return Data(c); |
|
|
} |
|
1204 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::sin); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::sin); |
1205 |
} |
} |
1206 |
|
|
1207 |
Data |
Data |
1208 |
Data::cos() const |
Data::cos() const |
1209 |
{ |
{ |
1210 |
if (isLazy()) |
MAKELAZYOP(COS) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),COS); |
|
|
return Data(c); |
|
|
} |
|
1211 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::cos); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::cos); |
1212 |
} |
} |
1213 |
|
|
1214 |
Data |
Data |
1215 |
Data::tan() const |
Data::tan() const |
1216 |
{ |
{ |
1217 |
if (isLazy()) |
MAKELAZYOP(TAN) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),TAN); |
|
|
return Data(c); |
|
|
} |
|
1218 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::tan); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::tan); |
1219 |
} |
} |
1220 |
|
|
1221 |
Data |
Data |
1222 |
Data::asin() const |
Data::asin() const |
1223 |
{ |
{ |
1224 |
if (isLazy()) |
MAKELAZYOP(ASIN) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),ASIN); |
|
|
return Data(c); |
|
|
} |
|
1225 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::asin); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::asin); |
1226 |
} |
} |
1227 |
|
|
1228 |
Data |
Data |
1229 |
Data::acos() const |
Data::acos() const |
1230 |
{ |
{ |
1231 |
if (isLazy()) |
MAKELAZYOP(ACOS) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),ACOS); |
|
|
return Data(c); |
|
|
} |
|
1232 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::acos); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::acos); |
1233 |
} |
} |
1234 |
|
|
1236 |
Data |
Data |
1237 |
Data::atan() const |
Data::atan() const |
1238 |
{ |
{ |
1239 |
if (isLazy()) |
MAKELAZYOP(ATAN) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),ATAN); |
|
|
return Data(c); |
|
|
} |
|
1240 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::atan); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::atan); |
1241 |
} |
} |
1242 |
|
|
1243 |
Data |
Data |
1244 |
Data::sinh() const |
Data::sinh() const |
1245 |
{ |
{ |
1246 |
if (isLazy()) |
MAKELAZYOP(SINH) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),SINH); |
|
|
return Data(c); |
|
|
} |
|
1247 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::sinh); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::sinh); |
1248 |
} |
} |
1249 |
|
|
1250 |
Data |
Data |
1251 |
Data::cosh() const |
Data::cosh() const |
1252 |
{ |
{ |
1253 |
if (isLazy()) |
MAKELAZYOP(COSH) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),COSH); |
|
|
return Data(c); |
|
|
} |
|
1254 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::cosh); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::cosh); |
1255 |
} |
} |
1256 |
|
|
1257 |
Data |
Data |
1258 |
Data::tanh() const |
Data::tanh() const |
1259 |
{ |
{ |
1260 |
if (isLazy()) |
MAKELAZYOP(TANH) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),TANH); |
|
|
return Data(c); |
|
|
} |
|
1261 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::tanh); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::tanh); |
1262 |
} |
} |
1263 |
|
|
1268 |
#if defined (_WIN32) && !defined(__INTEL_COMPILER) |
#if defined (_WIN32) && !defined(__INTEL_COMPILER) |
1269 |
throw DataException("Error - Data:: erf function is not supported on _WIN32 platforms."); |
throw DataException("Error - Data:: erf function is not supported on _WIN32 platforms."); |
1270 |
#else |
#else |
1271 |
if (isLazy()) |
MAKELAZYOP(ERF) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),ERF); |
|
|
return Data(c); |
|
|
} |
|
1272 |
return C_TensorUnaryOperation(*this, ::erf); |
return C_TensorUnaryOperation(*this, ::erf); |
1273 |
#endif |
#endif |
1274 |
} |
} |
1276 |
Data |
Data |
1277 |
Data::asinh() const |
Data::asinh() const |
1278 |
{ |
{ |
1279 |
if (isLazy()) |
MAKELAZYOP(ASINH) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),ASINH); |
|
|
return Data(c); |
|
|
} |
|
1280 |
#if defined (_WIN32) && !defined(__INTEL_COMPILER) |
#if defined (_WIN32) && !defined(__INTEL_COMPILER) |
1281 |
return C_TensorUnaryOperation(*this, escript::asinh_substitute); |
return C_TensorUnaryOperation(*this, escript::asinh_substitute); |
1282 |
#else |
#else |
1287 |
Data |
Data |
1288 |
Data::acosh() const |
Data::acosh() const |
1289 |
{ |
{ |
1290 |
if (isLazy()) |
MAKELAZYOP(ACOSH) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),ACOSH); |
|
|
return Data(c); |
|
|
} |
|
1291 |
#if defined (_WIN32) && !defined(__INTEL_COMPILER) |
#if defined (_WIN32) && !defined(__INTEL_COMPILER) |
1292 |
return C_TensorUnaryOperation(*this, escript::acosh_substitute); |
return C_TensorUnaryOperation(*this, escript::acosh_substitute); |
1293 |
#else |
#else |
1298 |
Data |
Data |
1299 |
Data::atanh() const |
Data::atanh() const |
1300 |
{ |
{ |
1301 |
if (isLazy()) |
MAKELAZYOP(ATANH) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),ATANH); |
|
|
return Data(c); |
|
|
} |
|
1302 |
#if defined (_WIN32) && !defined(__INTEL_COMPILER) |
#if defined (_WIN32) && !defined(__INTEL_COMPILER) |
1303 |
return C_TensorUnaryOperation(*this, escript::atanh_substitute); |
return C_TensorUnaryOperation(*this, escript::atanh_substitute); |
1304 |
#else |
#else |
1308 |
|
|
1309 |
Data |
Data |
1310 |
Data::log10() const |
Data::log10() const |
1311 |
{ if (isLazy()) |
{ |
1312 |
{ |
MAKELAZYOP(LOG10) |
|
DataLazy* c=new DataLazy(borrowDataPtr(),LOG10); |
|
|
return Data(c); |
|
|
} |
|
1313 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::log10); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::log10); |
1314 |
} |
} |
1315 |
|
|
1316 |
Data |
Data |
1317 |
Data::log() const |
Data::log() const |
1318 |
{ |
{ |
1319 |
if (isLazy()) |
MAKELAZYOP(LOG) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),LOG); |
|
|
return Data(c); |
|
|
} |
|
1320 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::log); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::log); |
1321 |
} |
} |
1322 |
|
|
1323 |
Data |
Data |
1324 |
Data::sign() const |
Data::sign() const |
1325 |
{ |
{ |
1326 |
if (isLazy()) |
MAKELAZYOP(SIGN) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),SIGN); |
|
|
return Data(c); |
|
|
} |
|
1327 |
return C_TensorUnaryOperation(*this, escript::fsign); |
return C_TensorUnaryOperation(*this, escript::fsign); |
1328 |
} |
} |
1329 |
|
|
1330 |
Data |
Data |
1331 |
Data::abs() const |
Data::abs() const |
1332 |
{ |
{ |
1333 |
if (isLazy()) |
MAKELAZYOP(ABS) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),ABS); |
|
|
return Data(c); |
|
|
} |
|
1334 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::fabs); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::fabs); |
1335 |
} |
} |
1336 |
|
|
1337 |
Data |
Data |
1338 |
Data::neg() const |
Data::neg() const |
1339 |
{ |
{ |
1340 |
if (isLazy()) |
MAKELAZYOP(NEG) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),NEG); |
|
|
return Data(c); |
|
|
} |
|
1341 |
return C_TensorUnaryOperation(*this, negate<double>()); |
return C_TensorUnaryOperation(*this, negate<double>()); |
1342 |
} |
} |
1343 |
|
|
1354 |
|
|
1355 |
Data |
Data |
1356 |
Data::exp() const |
Data::exp() const |
1357 |
{ |
{ |
1358 |
if (isLazy()) |
MAKELAZYOP(EXP) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),EXP); |
|
|
return Data(c); |
|
|
} |
|
1359 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::exp); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::exp); |
1360 |
} |
} |
1361 |
|
|
1362 |
Data |
Data |
1363 |
Data::sqrt() const |
Data::sqrt() const |
1364 |
{ |
{ |
1365 |
if (isLazy()) |
MAKELAZYOP(SQRT) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),SQRT); |
|
|
return Data(c); |
|
|
} |
|
1366 |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::sqrt); |
return C_TensorUnaryOperation<double (*)(double)>(*this, ::sqrt); |
1367 |
} |
} |
1368 |
|
|
1576 |
else { |
else { |
1577 |
throw DataException("Error - Data::symmetric can only be calculated for rank 2 or 4 object."); |
throw DataException("Error - Data::symmetric can only be calculated for rank 2 or 4 object."); |
1578 |
} |
} |
1579 |
if (isLazy()) |
MAKELAZYOP(SYM) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),SYM); |
|
|
return Data(c); |
|
|
} |
|
1580 |
Data ev(0.,getDataPointShape(),getFunctionSpace()); |
Data ev(0.,getDataPointShape(),getFunctionSpace()); |
1581 |
ev.typeMatchRight(*this); |
ev.typeMatchRight(*this); |
1582 |
m_data->symmetric(ev.m_data.get()); |
m_data->symmetric(ev.m_data.get()); |
1586 |
Data |
Data |
1587 |
Data::nonsymmetric() const |
Data::nonsymmetric() const |
1588 |
{ |
{ |
1589 |
if (isLazy()) |
MAKELAZYOP(NSYM) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),NSYM); |
|
|
return Data(c); |
|
|
} |
|
1590 |
// check input |
// check input |
1591 |
DataTypes::ShapeType s=getDataPointShape(); |
DataTypes::ShapeType s=getDataPointShape(); |
1592 |
if (getDataPointRank()==2) { |
if (getDataPointRank()==2) { |
1621 |
Data |
Data |
1622 |
Data::trace(int axis_offset) const |
Data::trace(int axis_offset) const |
1623 |
{ |
{ |
1624 |
if (isLazy()) |
MAKELAZYOPOFF(TRACE,axis_offset) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),TRACE,axis_offset); |
|
|
return Data(c); |
|
|
} |
|
1625 |
DataTypes::ShapeType s=getDataPointShape(); |
DataTypes::ShapeType s=getDataPointShape(); |
1626 |
if (getDataPointRank()==2) { |
if (getDataPointRank()==2) { |
1627 |
DataTypes::ShapeType ev_shape; |
DataTypes::ShapeType ev_shape; |
1672 |
Data |
Data |
1673 |
Data::transpose(int axis_offset) const |
Data::transpose(int axis_offset) const |
1674 |
{ |
{ |
1675 |
if (isLazy()) |
MAKELAZYOPOFF(TRANS,axis_offset) |
|
{ |
|
|
DataLazy* c=new DataLazy(borrowDataPtr(),TRANS,axis_offset); |
|
|
return Data(c); |
|
|
} |
|
1676 |
DataTypes::ShapeType s=getDataPointShape(); |
DataTypes::ShapeType s=getDataPointShape(); |
1677 |
DataTypes::ShapeType ev_shape; |
DataTypes::ShapeType ev_shape; |
1678 |
// Here's the equivalent of python s_out=s[axis_offset:]+s[:axis_offset] |
// Here's the equivalent of python s_out=s[axis_offset:]+s[:axis_offset] |
1868 |
if (isProtected()) { |
if (isProtected()) { |
1869 |
throw DataException("Error - attempt to update protected Data object."); |
throw DataException("Error - attempt to update protected Data object."); |
1870 |
} |
} |
1871 |
if (isLazy() || right.isLazy()) |
MAKELAZYBINSELF(right,ADD) // for lazy + is equivalent to += |
1872 |
{ |
binaryOp(right,plus<double>()); |
1873 |
DataLazy* c=new DataLazy(m_data,right.borrowDataPtr(),ADD); // for lazy + is equivalent to += |
return (*this); |
|
m_data=c->getPtr(); |
|
|
return (*this); |
|
|
} |
|
|
else |
|
|
{ |
|
|
binaryOp(right,plus<double>()); |
|
|
return (*this); |
|
|
} |
|
1874 |
} |
} |
1875 |
|
|
1876 |
Data& |
Data& |
1880 |
throw DataException("Error - attempt to update protected Data object."); |
throw DataException("Error - attempt to update protected Data object."); |
1881 |
} |
} |
1882 |
Data tmp(right,getFunctionSpace(),false); |
Data tmp(right,getFunctionSpace(),false); |
1883 |
if (isLazy()) |
MAKELAZYBINSELF(tmp,ADD) |
1884 |
{ |
binaryOp(tmp,plus<double>()); |
1885 |
DataLazy* c=new DataLazy(m_data,tmp.borrowDataPtr(),ADD); // for lazy + is equivalent to += |
return (*this); |
|
m_data=c->getPtr(); |
|
|
return (*this); |
|
|
} |
|
|
else |
|
|
{ |
|
|
binaryOp(tmp,plus<double>()); |
|
|
return (*this); |
|
|
} |
|
1886 |
} |
} |
1887 |
|
|
1888 |
// Hmmm, operator= makes a deep copy but the copy constructor does not? |
// Hmmm, operator= makes a deep copy but the copy constructor does not? |
1899 |
if (isProtected()) { |
if (isProtected()) { |
1900 |
throw DataException("Error - attempt to update protected Data object."); |
throw DataException("Error - attempt to update protected Data object."); |
1901 |
} |
} |
1902 |
if (isLazy() || right.isLazy()) |
MAKELAZYBINSELF(right,SUB) |
1903 |
{ |
binaryOp(right,minus<double>()); |
1904 |
DataLazy* c=new DataLazy(m_data,right.borrowDataPtr(),SUB); // for lazy - is equivalent to -= |
return (*this); |
|
m_data=c->getPtr(); |
|
|
return (*this); |
|
|
} |
|
|
else |
|
|
{ |
|
|
binaryOp(right,minus<double>()); |
|
|
return (*this); |
|
|
} |
|
1905 |
} |
} |
1906 |
|
|
1907 |
Data& |
Data& |
1911 |
throw DataException("Error - attempt to update protected Data object."); |
throw DataException("Error - attempt to update protected Data object."); |
1912 |
} |
} |
1913 |
Data tmp(right,getFunctionSpace(),false); |
Data tmp(right,getFunctionSpace(),false); |
1914 |
if (isLazy()) |
MAKELAZYBINSELF(tmp,SUB) |
1915 |
{ |
binaryOp(tmp,minus<double>()); |
1916 |
DataLazy* c=new DataLazy(m_data,tmp.borrowDataPtr(),SUB); // for lazy - is equivalent to -= |
return (*this); |
|
m_data=c->getPtr(); |
|
|
return (*this); |
|
|
} |
|
|
else |
|
|
{ |
|
|
binaryOp(tmp,minus<double>()); |
|
|
return (*this); |
|
|
} |
|
1917 |
} |
} |
1918 |
|
|
1919 |
Data& |
Data& |
1922 |
if (isProtected()) { |
if (isProtected()) { |
1923 |
throw DataException("Error - attempt to update protected Data object."); |
throw DataException("Error - attempt to update protected Data object."); |
1924 |
} |
} |
1925 |
if (isLazy() || right.isLazy()) |
MAKELAZYBINSELF(right,MUL) |
1926 |
{ |
binaryOp(right,multiplies<double>()); |
1927 |
DataLazy* c=new DataLazy(m_data,right.borrowDataPtr(),MUL); // for lazy * is equivalent to *= |
return (*this); |
|
m_data=c->getPtr(); |
|
|
return (*this); |
|
|
} |
|
|
else |
|
|
{ |
|
|
binaryOp(right,multiplies<double>()); |
|
|
return (*this); |
|
|
} |
|
1928 |
} |
} |
1929 |
|
|
1930 |
Data& |
Data& |
1934 |
throw DataException("Error - attempt to update protected Data object."); |
throw DataException("Error - attempt to update protected Data object."); |
1935 |
} |
} |
1936 |
Data tmp(right,getFunctionSpace(),false); |
Data tmp(right,getFunctionSpace(),false); |
1937 |
if (isLazy()) |
MAKELAZYBINSELF(tmp,MUL) |
1938 |
{ |
binaryOp(tmp,multiplies<double>()); |
1939 |
DataLazy* c=new DataLazy(m_data,tmp.borrowDataPtr(),MUL); // for lazy * is equivalent to *= |
return (*this); |
|
m_data=c->getPtr(); |
|
|
return (*this); |
|
|
} |
|
|
else |
|
|
{ |
|
|
binaryOp(tmp,multiplies<double>()); |
|
|
return (*this); |
|
|
} |
|
1940 |
} |
} |
1941 |
|
|
1942 |
Data& |
Data& |
1945 |
if (isProtected()) { |
if (isProtected()) { |
1946 |
throw DataException("Error - attempt to update protected Data object."); |
throw DataException("Error - attempt to update protected Data object."); |
1947 |
} |
} |
1948 |
if (isLazy() || right.isLazy()) |
MAKELAZYBINSELF(right,DIV) |
1949 |
{ |
binaryOp(right,divides<double>()); |
1950 |
DataLazy* c=new DataLazy(m_data,right.borrowDataPtr(),DIV); // for lazy / is equivalent to /= |
return (*this); |
|
m_data=c->getPtr(); |
|
|
return (*this); |
|
|
} |
|
|
else |
|
|
{ |
|
|
binaryOp(right,divides<double>()); |
|
|
return (*this); |
|
|
} |
|
1951 |
} |
} |
1952 |
|
|
1953 |
Data& |
Data& |
1957 |
throw DataException("Error - attempt to update protected Data object."); |
throw DataException("Error - attempt to update protected Data object."); |
1958 |
} |
} |
1959 |
Data tmp(right,getFunctionSpace(),false); |
Data tmp(right,getFunctionSpace(),false); |
1960 |
if (isLazy()) |
MAKELAZYBINSELF(tmp,DIV) |
1961 |
{ |
binaryOp(tmp,divides<double>()); |
1962 |
DataLazy* c=new DataLazy(m_data,tmp.borrowDataPtr(),DIV); // for lazy / is equivalent to /= |
return (*this); |
|
m_data=c->getPtr(); |
|
|
return (*this); |
|
|
} |
|
|
else |
|
|
{ |
|
|
binaryOp(tmp,divides<double>()); |
|
|
return (*this); |
|
|
} |
|
1963 |
} |
} |
1964 |
|
|
1965 |
Data |
Data |
1979 |
Data |
Data |
1980 |
Data::powD(const Data& right) const |
Data::powD(const Data& right) const |
1981 |
{ |
{ |
1982 |
if (isLazy() || right.isLazy()) |
MAKELAZYBIN(right,POW) |
|
{ |
|
|
DataLazy* c=new DataLazy(m_data,right.borrowDataPtr(),POW); |
|
|
return Data(c); |
|
|
} |
|
1983 |
return C_TensorBinaryOperation<double (*)(double, double)>(*this, right, ::pow); |
return C_TensorBinaryOperation<double (*)(double, double)>(*this, right, ::pow); |
1984 |
} |
} |
1985 |
|
|
1988 |
Data |
Data |
1989 |
escript::operator+(const Data& left, const Data& right) |
escript::operator+(const Data& left, const Data& right) |
1990 |
{ |
{ |
1991 |
if (left.isLazy() || right.isLazy()) |
MAKELAZYBIN2(left,right,ADD) |
|
{ |
|
|
DataLazy* c=new DataLazy(left.borrowDataPtr(),right.borrowDataPtr(),ADD); |
|
|
return Data(c); |
|
|
} |
|
1992 |
return C_TensorBinaryOperation(left, right, plus<double>()); |
return C_TensorBinaryOperation(left, right, plus<double>()); |
1993 |
} |
} |
1994 |
|
|
1997 |
Data |
Data |
1998 |
escript::operator-(const Data& left, const Data& right) |
escript::operator-(const Data& left, const Data& right) |
1999 |
{ |
{ |
2000 |
if (left.isLazy() || right.isLazy()) |
MAKELAZYBIN2(left,right,SUB) |
|
{ |
|
|
DataLazy* c=new DataLazy(left.borrowDataPtr(),right.borrowDataPtr(),SUB); |
|
|
return Data(c); |
|
|
} |
|
2001 |
return C_TensorBinaryOperation(left, right, minus<double>()); |
return C_TensorBinaryOperation(left, right, minus<double>()); |
2002 |
} |
} |
2003 |
|
|
2006 |
Data |
Data |
2007 |
escript::operator*(const Data& left, const Data& right) |
escript::operator*(const Data& left, const Data& right) |
2008 |
{ |
{ |
2009 |
if (left.isLazy() || right.isLazy()) |
MAKELAZYBIN2(left,right,MUL) |
|
{ |
|
|
DataLazy* c=new DataLazy(left.borrowDataPtr(),right.borrowDataPtr(),MUL); |
|
|
return Data(c); |
|
|
} |
|
2010 |
return C_TensorBinaryOperation(left, right, multiplies<double>()); |
return C_TensorBinaryOperation(left, right, multiplies<double>()); |
2011 |
} |
} |
2012 |
|
|
2015 |
Data |
Data |
2016 |
escript::operator/(const Data& left, const Data& right) |
escript::operator/(const Data& left, const Data& right) |
2017 |
{ |
{ |
2018 |
if (left.isLazy() || right.isLazy()) |
MAKELAZYBIN2(left,right,DIV) |
|
{ |
|
|
DataLazy* c=new DataLazy(left.borrowDataPtr(),right.borrowDataPtr(),DIV); |
|
|
return Data(c); |
|
|
} |
|
2019 |
return C_TensorBinaryOperation(left, right, divides<double>()); |
return C_TensorBinaryOperation(left, right, divides<double>()); |
2020 |
} |
} |
2021 |
|
|
2024 |
Data |
Data |
2025 |
escript::operator+(const Data& left, const boost::python::object& right) |
escript::operator+(const Data& left, const boost::python::object& right) |
2026 |
{ |
{ |
2027 |
if (left.isLazy()) |
Data tmp(right,left.getFunctionSpace(),false); |
2028 |
{ |
MAKELAZYBIN2(left,tmp,ADD) |
2029 |
DataLazy* c=new DataLazy(left.borrowDataPtr(),Data(right,left.getFunctionSpace(),false).borrowDataPtr(),ADD); |
return left+tmp; |
|
return Data(c); |
|
|
} |
|
|
return left+Data(right,left.getFunctionSpace(),false); |
|
2030 |
} |
} |
2031 |
|
|
2032 |
// |
// |
2034 |
Data |
Data |
2035 |
escript::operator-(const Data& left, const boost::python::object& right) |
escript::operator-(const Data& left, const boost::python::object& right) |
2036 |
{ |
{ |
2037 |
if (left.isLazy()) |
Data tmp(right,left.getFunctionSpace(),false); |
2038 |
{ |
MAKELAZYBIN2(left,tmp,SUB) |
2039 |
DataLazy* c=new DataLazy(left.borrowDataPtr(),Data(right,left.getFunctionSpace(),false).borrowDataPtr(),SUB); |
return left-tmp; |
|
return Data(c); |
|
|
} |
|
|
return left-Data(right,left.getFunctionSpace(),false); |
|
2040 |
} |
} |
2041 |
|
|
2042 |
// |
// |
2044 |
Data |
Data |
2045 |
escript::operator*(const Data& left, const boost::python::object& right) |
escript::operator*(const Data& left, const boost::python::object& right) |
2046 |
{ |
{ |
2047 |
if (left.isLazy()) |
Data tmp(right,left.getFunctionSpace(),false); |
2048 |
{ |
MAKELAZYBIN2(left,tmp,MUL) |
2049 |
DataLazy* c=new DataLazy(left.borrowDataPtr(),Data(right,left.getFunctionSpace(),false).borrowDataPtr(),MUL); |
return left*tmp; |
|
return Data(c); |
|
|
} |
|
|
return left*Data(right,left.getFunctionSpace(),false); |
|
2050 |
} |
} |
2051 |
|
|
2052 |
// |
// |
2054 |
Data |
Data |
2055 |
escript::operator/(const Data& left, const boost::python::object& right) |
escript::operator/(const Data& left, const boost::python::object& right) |
2056 |
{ |
{ |
2057 |
if (left.isLazy()) |
Data tmp(right,left.getFunctionSpace(),false); |
2058 |
{ |
MAKELAZYBIN2(left,tmp,DIV) |
2059 |
DataLazy* c=new DataLazy(left.borrowDataPtr(),Data(right,left.getFunctionSpace(),false).borrowDataPtr(),DIV); |
return left/tmp; |
|
return Data(c); |
|
|
} |
|
|
return left/Data(right,left.getFunctionSpace(),false); |
|
2060 |
} |
} |
2061 |
|
|
2062 |
// |
// |
2064 |
Data |
Data |
2065 |
escript::operator+(const boost::python::object& left, const Data& right) |
escript::operator+(const boost::python::object& left, const Data& right) |
2066 |
{ |
{ |
2067 |
if (right.isLazy()) |
Data tmp(left,right.getFunctionSpace(),false); |
2068 |
{ |
MAKELAZYBIN2(tmp,right,ADD) |
2069 |
DataLazy* c=new DataLazy(Data(left,right.getFunctionSpace(),false).borrowDataPtr(),right.borrowDataPtr(),ADD); |
return tmp+right; |
|
return Data(c); |
|
|
} |
|
|
return Data(left,right.getFunctionSpace(),false)+right; |
|
2070 |
} |
} |
2071 |
|
|
2072 |
// |
// |
2074 |
Data |
Data |
2075 |
escript::operator-(const boost::python::object& left, const Data& right) |
escript::operator-(const boost::python::object& left, const Data& right) |
2076 |
{ |
{ |
2077 |
if (right.isLazy()) |
Data tmp(left,right.getFunctionSpace(),false); |
2078 |
{ |
MAKELAZYBIN2(tmp,right,SUB) |
2079 |
DataLazy* c=new DataLazy(Data(left,right.getFunctionSpace(),false).borrowDataPtr(),right.borrowDataPtr(),SUB); |
return tmp-right; |
|
return Data(c); |
|
|
} |
|
|
return Data(left,right.getFunctionSpace(),false)-right; |
|
2080 |
} |
} |
2081 |
|
|
2082 |
// |
// |
2084 |
Data |
Data |
2085 |
escript::operator*(const boost::python::object& left, const Data& right) |
escript::operator*(const boost::python::object& left, const Data& right) |
2086 |
{ |
{ |
2087 |
if (right.isLazy()) |
Data tmp(left,right.getFunctionSpace(),false); |
2088 |
{ |
MAKELAZYBIN2(tmp,right,MUL) |
2089 |
DataLazy* c=new DataLazy(Data(left,right.getFunctionSpace(),false).borrowDataPtr(),right.borrowDataPtr(),MUL); |
return tmp*right; |
|
return Data(c); |
|
|
} |
|
|
return Data(left,right.getFunctionSpace(),false)*right; |
|
2090 |
} |
} |
2091 |
|
|
2092 |
// |
// |
2094 |
Data |
Data |
2095 |
escript::operator/(const boost::python::object& left, const Data& right) |
escript::operator/(const boost::python::object& left, const Data& right) |
2096 |
{ |
{ |
2097 |
if (right.isLazy()) |
Data tmp(left,right.getFunctionSpace(),false); |
2098 |
{ |
MAKELAZYBIN2(tmp,right,DIV) |
2099 |
DataLazy* c=new DataLazy(Data(left,right.getFunctionSpace(),false).borrowDataPtr(),right.borrowDataPtr(),DIV); |
return tmp/right; |
|
return Data(c); |
|
|
} |
|
|
return Data(left,right.getFunctionSpace(),false)/right; |
|
2100 |
} |
} |
2101 |
|
|
2102 |
|
|