/[escript]/trunk/escript/src/Data.cpp
ViewVC logotype

Diff of /trunk/escript/src/Data.cpp

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

revision 2492 by gross, Wed Jun 24 01:28:57 2009 UTC revision 2496 by jfenwick, Fri Jun 26 06:09:47 2009 UTC
# Line 61  using namespace escript; Line 61  using namespace escript;
61      return Data(c);\      return Data(c);\
62    }    }
63    
64    #define MAKELAZYOP2(X,Y,Z) if (isLazy() || (AUTOLAZYON && m_data->isExpanded())) \
65      {\
66        DataLazy* c=new DataLazy(borrowDataPtr(),X,Y,Z);\
67        return Data(c);\
68      }
69    
70  #define MAKELAZYBINSELF(R,X)   if (isLazy() || R.isLazy() || (AUTOLAZYON && (isExpanded() || R.isExpanded()))) \  #define MAKELAZYBINSELF(R,X)   if (isLazy() || R.isLazy() || (AUTOLAZYON && (isExpanded() || R.isExpanded()))) \
71    {\    {\
72      DataLazy* c=new DataLazy(m_data,R.borrowDataPtr(),X);\      DataLazy* c=new DataLazy(m_data,R.borrowDataPtr(),X);\
# Line 1676  Data::minval() const Line 1682  Data::minval() const
1682  Data  Data
1683  Data::swapaxes(const int axis0, const int axis1) const  Data::swapaxes(const int axis0, const int axis1) const
1684  {  {
      if (isLazy())  
      {  
     Data temp(*this);  
     temp.resolve();  
     return temp.swapaxes(axis0,axis1);  
      }  
1685       int axis0_tmp,axis1_tmp;       int axis0_tmp,axis1_tmp;
1686       DataTypes::ShapeType s=getDataPointShape();       DataTypes::ShapeType s=getDataPointShape();
1687       DataTypes::ShapeType ev_shape;       DataTypes::ShapeType ev_shape;
# Line 1700  Data::swapaxes(const int axis0, const in Line 1700  Data::swapaxes(const int axis0, const in
1700       if (axis0 == axis1) {       if (axis0 == axis1) {
1701           throw DataException("Error - Data::swapaxes: axis indices must be different.");           throw DataException("Error - Data::swapaxes: axis indices must be different.");
1702       }       }
1703       if (axis0 > axis1) {       MAKELAZYOP2(SWAP,axis0,axis1)
1704           axis0_tmp=axis1;       if (axis0 > axis1)
1705           axis1_tmp=axis0;       {
1706       } else {      axis0_tmp=axis1;
1707           axis0_tmp=axis0;      axis1_tmp=axis0;
          axis1_tmp=axis1;  
1708       }       }
1709       for (int i=0; i<rank; i++) {       else
1710         if (i == axis0_tmp) {       {
1711            ev_shape.push_back(s[axis1_tmp]);      axis0_tmp=axis0;
1712         } else if (i == axis1_tmp) {      axis1_tmp=axis1;
1713            ev_shape.push_back(s[axis0_tmp]);       }
1714         } else {       for (int i=0; i<rank; i++)
1715            ev_shape.push_back(s[i]);       {
1716         }      if (i == axis0_tmp)
1717        {
1718            ev_shape.push_back(s[axis1_tmp]);
1719        }
1720        else if (i == axis1_tmp)
1721        {
1722            ev_shape.push_back(s[axis0_tmp]);
1723        }
1724        else
1725        {
1726            ev_shape.push_back(s[i]);
1727        }
1728       }       }
1729       Data ev(0.,ev_shape,getFunctionSpace());       Data ev(0.,ev_shape,getFunctionSpace());
1730       ev.typeMatchRight(*this);       ev.typeMatchRight(*this);
1731       m_data->swapaxes(ev.m_data.get(), axis0_tmp, axis1_tmp);       m_data->swapaxes(ev.m_data.get(), axis0_tmp, axis1_tmp);
1732       return ev;       return ev;
   
1733  }  }
1734    
1735  Data  Data

Legend:
Removed from v.2492  
changed lines
  Added in v.2496

  ViewVC Help
Powered by ViewVC 1.1.26