/[escript]/branches/schroedinger/escript/src/Data.cpp
ViewVC logotype

Diff of /branches/schroedinger/escript/src/Data.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1887 by jfenwick, Wed Oct 15 01:34:18 2008 UTC revision 1888 by jfenwick, Wed Oct 15 04:00:21 2008 UTC
# Line 604  Data::tag() Line 604  Data::tag()
604  Data  Data
605  Data::oneOver() const  Data::oneOver() const
606  {  {
607      if (isLazy())
608      {
609        DataLazy* c=new DataLazy(borrowDataPtr(),RECIP);
610        return Data(c);
611      }
612    return C_TensorUnaryOperation(*this, bind1st(divides<double>(),1.));    return C_TensorUnaryOperation(*this, bind1st(divides<double>(),1.));
613  }  }
614    
615  Data  Data
616  Data::wherePositive() const  Data::wherePositive() const
617  {  {
618      if (isLazy())
619      {
620        DataLazy* c=new DataLazy(borrowDataPtr(),GZ);
621        return Data(c);
622      }
623    return C_TensorUnaryOperation(*this, bind2nd(greater<double>(),0.0));    return C_TensorUnaryOperation(*this, bind2nd(greater<double>(),0.0));
624  }  }
625    
626  Data  Data
627  Data::whereNegative() const  Data::whereNegative() const
628  {  {
629      if (isLazy())
630      {
631        DataLazy* c=new DataLazy(borrowDataPtr(),LZ);
632        return Data(c);
633      }
634    return C_TensorUnaryOperation(*this, bind2nd(less<double>(),0.0));    return C_TensorUnaryOperation(*this, bind2nd(less<double>(),0.0));
635  }  }
636    
637  Data  Data
638  Data::whereNonNegative() const  Data::whereNonNegative() const
639  {  {
640      if (isLazy())
641      {
642        DataLazy* c=new DataLazy(borrowDataPtr(),GEZ);
643        return Data(c);
644      }
645    return C_TensorUnaryOperation(*this, bind2nd(greater_equal<double>(),0.0));    return C_TensorUnaryOperation(*this, bind2nd(greater_equal<double>(),0.0));
646  }  }
647    
648  Data  Data
649  Data::whereNonPositive() const  Data::whereNonPositive() const
650  {  {
651      if (isLazy())
652      {
653        DataLazy* c=new DataLazy(borrowDataPtr(),LEZ);
654        return Data(c);
655      }
656    return C_TensorUnaryOperation(*this, bind2nd(less_equal<double>(),0.0));    return C_TensorUnaryOperation(*this, bind2nd(less_equal<double>(),0.0));
657  }  }
658    
# Line 1310  Data::pos() const Line 1335  Data::pos() const
1335    
1336  Data  Data
1337  Data::exp() const  Data::exp() const
1338  {  {  
1339      if (isLazy())
1340      {
1341        DataLazy* c=new DataLazy(borrowDataPtr(),EXP);
1342        return Data(c);
1343      }
1344    return C_TensorUnaryOperation<double (*)(double)>(*this, ::exp);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::exp);
1345  }  }
1346    
1347  Data  Data
1348  Data::sqrt() const  Data::sqrt() const
1349  {  {
1350      if (isLazy())
1351      {
1352        DataLazy* c=new DataLazy(borrowDataPtr(),SQRT);
1353        return Data(c);
1354      }
1355    return C_TensorUnaryOperation<double (*)(double)>(*this, ::sqrt);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::sqrt);
1356  }  }
1357    
1358  double  double
1359  Data::Lsup() const  Data::Lsup_const() const
1360    {
1361       if (isLazy())
1362       {
1363        throw DataException("Error - cannot compute Lsup for constant lazy data.");
1364       }
1365       return LsupWorker();
1366    }
1367    
1368    double
1369    Data::Lsup()
1370    {
1371       if (isLazy())
1372       {
1373        expand();
1374       }
1375       return LsupWorker();
1376    }
1377    
1378    double
1379    Data::sup_const() const
1380    {
1381       if (isLazy())
1382       {
1383        throw DataException("Error - cannot compute sup for constant lazy data.");
1384       }
1385       return supWorker();
1386    }
1387    
1388    double
1389    Data::sup()
1390    {
1391       if (isLazy())
1392       {
1393        expand();
1394       }
1395       return supWorker();
1396    }
1397    
1398    double
1399    Data::inf_const() const
1400    {
1401       if (isLazy())
1402       {
1403        throw DataException("Error - cannot compute inf for constant lazy data.");
1404       }
1405       return infWorker();
1406    }
1407    
1408    double
1409    Data::inf()
1410    {
1411       if (isLazy())
1412       {
1413        expand();
1414       }
1415       return infWorker();
1416    }
1417    
1418    double
1419    Data::LsupWorker() const
1420  {  {
1421    double localValue;    double localValue;
1422    //    //
# Line 1339  Data::Lsup() const Line 1434  Data::Lsup() const
1434  }  }
1435    
1436  double  double
1437  Data::sup() const  Data::supWorker() const
1438  {  {
1439    double localValue;    double localValue;
1440    //    //
# Line 1356  Data::sup() const Line 1451  Data::sup() const
1451  }  }
1452    
1453  double  double
1454  Data::inf() const  Data::infWorker() const
1455  {  {
1456    double localValue;    double localValue;
1457    //    //
# Line 2518  Data::toString() const Line 2613  Data::toString() const
2613      if (getNumDataPoints()*getDataPointSize()>TOO_MANY_POINTS)      if (getNumDataPoints()*getDataPointSize()>TOO_MANY_POINTS)
2614      {      {
2615      stringstream temp;      stringstream temp;
2616      temp << "Summary: inf="<< inf() << " sup=" << sup() << " data points=" << getNumDataPoints();      temp << "Summary: inf="<< inf_const() << " sup=" << sup_const() << " data points=" << getNumDataPoints();
2617      return  temp.str();      return  temp.str();
2618      }      }
2619      return m_data->toString();      return m_data->toString();

Legend:
Removed from v.1887  
changed lines
  Added in v.1888

  ViewVC Help
Powered by ViewVC 1.1.26