/[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 790 by bcumming, Wed Jul 26 23:12:34 2006 UTC revision 800 by gross, Tue Aug 8 11:23:18 2006 UTC
# Line 1316  Data::minval() const Line 1316  Data::minval() const
1316  }  }
1317    
1318  Data  Data
1319  Data::trace() const  Data::swap(int axis_offset) const
1320  {  {
1321  #if defined DOPROF       #if defined DOPROF
1322    profData->reduction2++;       profData->unary++;
1323  #endif       #endif
1324    Trace trace_func;       DataArrayView::ShapeType s=getDataPointShape();
1325    return dp_algorithm(trace_func,0);       DataArrayView::ShapeType ev_shape;
1326         // Here's the equivalent of python s_out=s[axis_offset:]+s[:axis_offset]
1327         // which goes thru all shape vector elements starting with axis_offset (at index=rank wrap around to 0)
1328         int rank=getDataPointRank();
1329         if (axis_offset<0 || axis_offset+1>rank) {
1330            throw DataException("Error - Data::transpose must have 0 <= axis_offset <= rank-1=" + rank-1);
1331         }
1332         for (int i=0; i<rank; i++) {
1333           if (i == axis_offset) {
1334              ev_shape.push_back(s[axis_offset+1]);
1335           } else if (i == axis_offset+1) {
1336              ev_shape.push_back(s[axis_offset]);
1337           } else {
1338              ev_shape.push_back(s[i]);
1339           }
1340         }
1341         Data ev(0.,ev_shape,getFunctionSpace());
1342         ev.typeMatchRight(*this);
1343         m_data->swap(ev.m_data.get(), axis_offset);
1344         return ev;
1345    
1346  }  }
1347    
1348  Data  Data
# Line 1388  Data::nonsymmetric() const Line 1408  Data::nonsymmetric() const
1408  }  }
1409    
1410  Data  Data
1411  Data::matrixtrace(int axis_offset) const  Data::trace(int axis_offset) const
1412  {  {
1413       #if defined DOPROF       #if defined DOPROF
1414          profData->unary++;          profData->unary++;
# Line 1398  Data::matrixtrace(int axis_offset) const Line 1418  Data::matrixtrace(int axis_offset) const
1418          DataArrayView::ShapeType ev_shape;          DataArrayView::ShapeType ev_shape;
1419          Data ev(0.,ev_shape,getFunctionSpace());          Data ev(0.,ev_shape,getFunctionSpace());
1420          ev.typeMatchRight(*this);          ev.typeMatchRight(*this);
1421          m_data->matrixtrace(ev.m_data.get(), axis_offset);          m_data->trace(ev.m_data.get(), axis_offset);
1422          return ev;          return ev;
1423       }       }
1424       if (getDataPointRank()==3) {       if (getDataPointRank()==3) {
# Line 1413  Data::matrixtrace(int axis_offset) const Line 1433  Data::matrixtrace(int axis_offset) const
1433          }          }
1434          Data ev(0.,ev_shape,getFunctionSpace());          Data ev(0.,ev_shape,getFunctionSpace());
1435          ev.typeMatchRight(*this);          ev.typeMatchRight(*this);
1436          m_data->matrixtrace(ev.m_data.get(), axis_offset);          m_data->trace(ev.m_data.get(), axis_offset);
1437          return ev;          return ev;
1438       }       }
1439       if (getDataPointRank()==4) {       if (getDataPointRank()==4) {
# Line 1432  Data::matrixtrace(int axis_offset) const Line 1452  Data::matrixtrace(int axis_offset) const
1452      }      }
1453          Data ev(0.,ev_shape,getFunctionSpace());          Data ev(0.,ev_shape,getFunctionSpace());
1454          ev.typeMatchRight(*this);          ev.typeMatchRight(*this);
1455      m_data->matrixtrace(ev.m_data.get(), axis_offset);      m_data->trace(ev.m_data.get(), axis_offset);
1456          return ev;          return ev;
1457       }       }
1458       else {       else {
1459          throw DataException("Error - Data::matrixtrace can only be calculated for rank 2, 3 or 4 object.");          throw DataException("Error - Data::trace can only be calculated for rank 2, 3 or 4 object.");
1460       }       }
1461  }  }
1462    
1463  Data  Data
1464  Data::transpose(int axis_offset) const  Data::transpose(int axis_offset) const
1465  {  {
1466  #if defined DOPROF       #if defined DOPROF
1467       profData->reduction2++;       profData->unary++;
1468  #endif       #endif
1469       DataArrayView::ShapeType s=getDataPointShape();       DataArrayView::ShapeType s=getDataPointShape();
1470       DataArrayView::ShapeType ev_shape;       DataArrayView::ShapeType ev_shape;
1471       // 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]

Legend:
Removed from v.790  
changed lines
  Added in v.800

  ViewVC Help
Powered by ViewVC 1.1.26