/[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 1867 by jfenwick, Thu Oct 9 03:53:57 2008 UTC revision 1868 by jfenwick, Thu Oct 9 06:30:49 2008 UTC
# Line 150  Data::Data(DataAbstract* underlyingdata) Line 150  Data::Data(DataAbstract* underlyingdata)
150      m_protected=false;      m_protected=false;
151  }  }
152    
153    Data::Data(DataAbstract_ptr underlyingdata)
154    {
155        m_data=underlyingdata;
156        m_protected=false;
157    }
158    
159    
160  Data::Data(const numeric::array& value,  Data::Data(const numeric::array& value,
161         const FunctionSpace& what,         const FunctionSpace& what,
162             bool expanded)             bool expanded)
# Line 1707  Data::powD(const Data& right) const Line 1714  Data::powD(const Data& right) const
1714  Data  Data
1715  escript::operator+(const Data& left, const Data& right)  escript::operator+(const Data& left, const Data& right)
1716  {  {
1717      if (left.isLazy() || right.isLazy())
1718      {
1719        DataLazy* c=new DataLazy(left.borrowDataPtr(),right.borrowDataPtr(),ADD);
1720        return Data(c);
1721      }
1722    return C_TensorBinaryOperation(left, right, plus<double>());    return C_TensorBinaryOperation(left, right, plus<double>());
1723  }  }
1724    
# Line 1715  escript::operator+(const Data& left, con Line 1727  escript::operator+(const Data& left, con
1727  Data  Data
1728  escript::operator-(const Data& left, const Data& right)  escript::operator-(const Data& left, const Data& right)
1729  {  {
1730      if (left.isLazy() || right.isLazy())
1731      {
1732        DataLazy* c=new DataLazy(left.borrowDataPtr(),right.borrowDataPtr(),SUB);
1733        return Data(c);
1734      }
1735    return C_TensorBinaryOperation(left, right, minus<double>());    return C_TensorBinaryOperation(left, right, minus<double>());
1736  }  }
1737    
# Line 1723  escript::operator-(const Data& left, con Line 1740  escript::operator-(const Data& left, con
1740  Data  Data
1741  escript::operator*(const Data& left, const Data& right)  escript::operator*(const Data& left, const Data& right)
1742  {  {
1743      if (left.isLazy() || right.isLazy())
1744      {
1745        DataLazy* c=new DataLazy(left.borrowDataPtr(),right.borrowDataPtr(),MUL);
1746        return Data(c);
1747      }
1748    return C_TensorBinaryOperation(left, right, multiplies<double>());    return C_TensorBinaryOperation(left, right, multiplies<double>());
1749  }  }
1750    
# Line 1731  escript::operator*(const Data& left, con Line 1753  escript::operator*(const Data& left, con
1753  Data  Data
1754  escript::operator/(const Data& left, const Data& right)  escript::operator/(const Data& left, const Data& right)
1755  {  {
1756      if (left.isLazy() || right.isLazy())
1757      {
1758        DataLazy* c=new DataLazy(left.borrowDataPtr(),right.borrowDataPtr(),DIV);
1759        return Data(c);
1760      }
1761    return C_TensorBinaryOperation(left, right, divides<double>());    return C_TensorBinaryOperation(left, right, divides<double>());
1762  }  }
1763    
# Line 2418  Data::borrowData() const Line 2445  Data::borrowData() const
2445    return m_data.get();    return m_data.get();
2446  }  }
2447    
2448    // Not all that happy about returning a non-const from a const
2449    DataAbstract_ptr
2450    Data::borrowDataPtr() const
2451    {
2452      return m_data;
2453    }
2454    
2455    // Not all that happy about returning a non-const from a const
2456    DataReady_ptr
2457    Data::borrowReadyPtr() const
2458    {
2459       DataReady_ptr dr=dynamic_pointer_cast<DataReady>(m_data);
2460       EsysAssert((dr!=0), "Error - casting to DataReady.");
2461       return dr;
2462    }
2463    
2464  std::string  std::string
2465  Data::toString() const  Data::toString() const
2466  {  {
2467      static const DataTypes::ValueType::size_type TOO_MANY_POINTS=80;      static const DataTypes::ValueType::size_type TOO_MANY_POINTS=80;
2468        if (isLazy())
2469        {           // This needs to change back to printing out something useful once the summary ops
2470        return m_data->toString();  // are defined
2471        }
2472      if (getNumDataPoints()*getDataPointSize()>TOO_MANY_POINTS)      if (getNumDataPoints()*getDataPointSize()>TOO_MANY_POINTS)
2473      {      {
2474      stringstream temp;      stringstream temp;

Legend:
Removed from v.1867  
changed lines
  Added in v.1868

  ViewVC Help
Powered by ViewVC 1.1.26