/[escript]/trunk/escript/src/UnaryOp.h
ViewVC logotype

Diff of /trunk/escript/src/UnaryOp.h

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

revision 1388 by trankine, Fri Jan 11 07:45:58 2008 UTC revision 1796 by jfenwick, Wed Sep 17 01:45:46 2008 UTC
# Line 17  Line 17 
17  #define escript_UnaryOp_20040315_H  #define escript_UnaryOp_20040315_H
18  #include "system_dep.h"  #include "system_dep.h"
19    
 #include "DataArrayView.h"  
20  #include "DataConstant.h"  #include "DataConstant.h"
21  #include "DataTagged.h"  #include "DataTagged.h"
22  #include "DataExpanded.h"  #include "DataExpanded.h"
23    #include "DataTypes.h"
24    
25  namespace escript {  namespace escript {
26    
# Line 41  unaryOp(DataExpanded& data, Line 41  unaryOp(DataExpanded& data,
41          UnaryFunction operation)          UnaryFunction operation)
42  {  {
43    int i,j;    int i,j;
44    DataArrayView::ValueType::size_type numDPPSample=data.getNumDPPSample();    DataTypes::ValueType::size_type numDPPSample=data.getNumDPPSample();
45    DataArrayView::ValueType::size_type numSamples=data.getNumSamples();    DataTypes::ValueType::size_type numSamples=data.getNumSamples();
46      DataTypes::ValueType& left=data.getVector();
47      const DataTypes::ShapeType& shape=data.getShape();
48    #pragma omp parallel for private(i,j) schedule(static)    #pragma omp parallel for private(i,j) schedule(static)
49    for (i=0;i<numSamples;i++) {    for (i=0;i<numSamples;i++) {
50      for (j=0;j<numDPPSample;j++) {      for (j=0;j<numDPPSample;j++) {
51        data.getPointDataView().unaryOp(data.getPointOffset(i,j),operation);        //data.getPointDataView().unaryOp(data.getPointOffset(i,j),operation);
52          DataMaths::unaryOp(left,shape,data.getPointOffset(i,j),operation);
53      }      }
54    }    }
55  }  }
# Line 61  unaryOp(DataTagged& data, Line 64  unaryOp(DataTagged& data,
64    const DataTagged::DataMapType& lookup=data.getTagLookup();    const DataTagged::DataMapType& lookup=data.getTagLookup();
65    DataTagged::DataMapType::const_iterator i;    DataTagged::DataMapType::const_iterator i;
66    DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();    DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();
67    DataArrayView& dataView=data.getPointDataView();    //DataArrayView& dataView=data.getPointDataView();
68      DataTypes::ValueType& left=data.getVector();
69      const DataTypes::ShapeType& shape=data.getShape();
70    for (i=lookup.begin();i!=lookupEnd;i++) {    for (i=lookup.begin();i!=lookupEnd;i++) {
71      dataView.unaryOp(i->second,operation);  //    dataView.unaryOp(i->second,operation);
72        DataMaths::unaryOp(left,shape,i->second,operation);
73    }    }
74    // perform the operation on the default value    // perform the operation on the default value
75    data.getDefaultValue().unaryOp(operation);    //data.getDefaultValue().unaryOp(operation);
76      DataMaths::unaryOp(left,shape,data.getDefaultOffset(),operation);
77  }  }
78    
79  template <class UnaryFunction>  template <class UnaryFunction>
# Line 75  void Line 82  void
82  unaryOp(DataConstant& data,  unaryOp(DataConstant& data,
83          UnaryFunction operation)          UnaryFunction operation)
84  {  {
85    data.getPointDataView().unaryOp(operation);    //data.getPointDataView().unaryOp(operation);
86      DataMaths::unaryOp(data.getVector(),data.getShape(),0,operation);
87  }  }
88    
89  } // end of namespace  } // end of namespace

Legend:
Removed from v.1388  
changed lines
  Added in v.1796

  ViewVC Help
Powered by ViewVC 1.1.26