/[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 964 by gross, Tue Feb 13 05:10:26 2007 UTC revision 1118 by gross, Tue Apr 24 08:55:04 2007 UTC
# Line 38  using namespace boost::python; Line 38  using namespace boost::python;
38  using namespace boost;  using namespace boost;
39  using namespace escript;  using namespace escript;
40    
 #if defined DOPROF  
 //  
 // global table of profiling data for all Data objects  
 DataProf dataProfTable;  
 #endif  
   
41  Data::Data()  Data::Data()
42  {  {
43    //    //
# Line 52  Data::Data() Line 46  Data::Data()
46    shared_ptr<DataAbstract> temp_data(temp);    shared_ptr<DataAbstract> temp_data(temp);
47    m_data=temp_data;    m_data=temp_data;
48    m_protected=false;    m_protected=false;
 #if defined DOPROF  
   // create entry in global profiling table for this object  
   profData = dataProfTable.newData();  
 #endif  
49  }  }
50    
51  Data::Data(double value,  Data::Data(double value,
# Line 70  Data::Data(double value, Line 60  Data::Data(double value,
60    DataArray temp(dataPointShape,value);    DataArray temp(dataPointShape,value);
61    initialise(temp.getView(),what,expanded);    initialise(temp.getView(),what,expanded);
62    m_protected=false;    m_protected=false;
 #if defined DOPROF  
   // create entry in global profiling table for this object  
   profData = dataProfTable.newData();  
 #endif  
63  }  }
64    
65  Data::Data(double value,  Data::Data(double value,
# Line 85  Data::Data(double value, Line 71  Data::Data(double value,
71    pair<int,int> dataShape=what.getDataShape();    pair<int,int> dataShape=what.getDataShape();
72    initialise(temp.getView(),what,expanded);    initialise(temp.getView(),what,expanded);
73    m_protected=false;    m_protected=false;
 #if defined DOPROF  
   // create entry in global profiling table for this object  
   profData = dataProfTable.newData();  
 #endif  
74  }  }
75    
76  Data::Data(const Data& inData)  Data::Data(const Data& inData)
77  {  {
78    m_data=inData.m_data;    m_data=inData.m_data;
79    m_protected=inData.isProtected();    m_protected=inData.isProtected();
 #if defined DOPROF  
   // create entry in global profiling table for this object  
   profData = dataProfTable.newData();  
 #endif  
80  }  }
81    
82  Data::Data(const Data& inData,  Data::Data(const Data& inData,
# Line 110  Data::Data(const Data& inData, Line 88  Data::Data(const Data& inData,
88    shared_ptr<DataAbstract> temp_data(tmp);    shared_ptr<DataAbstract> temp_data(tmp);
89    m_data=temp_data;    m_data=temp_data;
90    m_protected=false;    m_protected=false;
 #if defined DOPROF  
   // create entry in global profiling table for this object  
   profData = dataProfTable.newData();  
 #endif  
91  }  }
92    
93  Data::Data(const Data& inData,  Data::Data(const Data& inData,
94             const FunctionSpace& functionspace)             const FunctionSpace& functionspace)
95  {  {
 #if defined DOPROF  
   // create entry in global profiling table for this object  
   profData = dataProfTable.newData();  
 #endif  
96    if (inData.getFunctionSpace()==functionspace) {    if (inData.getFunctionSpace()==functionspace) {
97      m_data=inData.m_data;      m_data=inData.m_data;
98    } else {    } else {
     #if defined DOPROF  
     profData->interpolate++;  
     #endif  
99      Data tmp(0,inData.getPointDataView().getShape(),functionspace,true);      Data tmp(0,inData.getPointDataView().getShape(),functionspace,true);
100      // Note: Must use a reference or pointer to a derived object      // Note: Must use a reference or pointer to a derived object
101      // in order to get polymorphic behaviour. Shouldn't really      // in order to get polymorphic behaviour. Shouldn't really
# Line 158  Data::Data(const DataTagged::TagListType Line 125  Data::Data(const DataTagged::TagListType
125    if (expanded) {    if (expanded) {
126      expand();      expand();
127    }    }
 #if defined DOPROF  
   // create entry in global profiling table for this object  
   profData = dataProfTable.newData();  
 #endif  
128  }  }
129    
130  Data::Data(const numeric::array& value,  Data::Data(const numeric::array& value,
# Line 170  Data::Data(const numeric::array& value, Line 133  Data::Data(const numeric::array& value,
133  {  {
134    initialise(value,what,expanded);    initialise(value,what,expanded);
135    m_protected=false;    m_protected=false;
 #if defined DOPROF  
   // create entry in global profiling table for this object  
   profData = dataProfTable.newData();  
 #endif  
136  }  }
137    
138  Data::Data(const DataArrayView& value,  Data::Data(const DataArrayView& value,
# Line 182  Data::Data(const DataArrayView& value, Line 141  Data::Data(const DataArrayView& value,
141  {  {
142    initialise(value,what,expanded);    initialise(value,what,expanded);
143    m_protected=false;    m_protected=false;
 #if defined DOPROF  
   // create entry in global profiling table for this object  
   profData = dataProfTable.newData();  
 #endif  
144  }  }
145    
146  Data::Data(const object& value,  Data::Data(const object& value,
# Line 195  Data::Data(const object& value, Line 150  Data::Data(const object& value,
150    numeric::array asNumArray(value);    numeric::array asNumArray(value);
151    initialise(asNumArray,what,expanded);    initialise(asNumArray,what,expanded);
152    m_protected=false;    m_protected=false;
 #if defined DOPROF  
   // create entry in global profiling table for this object  
   profData = dataProfTable.newData();  
 #endif  
153  }  }
154    
155  Data::Data(const object& value,  Data::Data(const object& value,
# Line 220  Data::Data(const object& value, Line 171  Data::Data(const object& value,
171      initialise(temp.getView(),other.getFunctionSpace(),false);      initialise(temp.getView(),other.getFunctionSpace(),false);
172    }    }
173    m_protected=false;    m_protected=false;
 #if defined DOPROF  
   // create entry in global profiling table for this object  
   profData = dataProfTable.newData();  
 #endif  
174  }  }
175    
176  Data::~Data()  Data::~Data()
# Line 266  Data::getShapeTuple() const Line 213  Data::getShapeTuple() const
213          throw DataException("Error - illegal Data rank.");          throw DataException("Error - illegal Data rank.");
214    }    }
215  }  }
   
216  void  void
217  Data::copy(const Data& other)  Data::copy(const Data& other)
218  {  {
# Line 319  Data::copy(const Data& other) Line 265  Data::copy(const Data& other)
265    throw DataException("Error - Copy not implemented for this Data type.");    throw DataException("Error - Copy not implemented for this Data type.");
266  }  }
267    
268    
269    void
270    Data::setToZero()
271    {
272      {
273        DataExpanded* temp=dynamic_cast<DataExpanded*>(m_data.get());
274        if (temp!=0) {
275           temp->setToZero();
276           return;
277        }
278      }
279      {
280        DataTagged* temp=dynamic_cast<DataTagged*>(m_data.get());
281        if (temp!=0) {
282          temp->setToZero();
283          return;
284        }
285      }
286      {
287        DataConstant* temp=dynamic_cast<DataConstant*>(m_data.get());
288        if (temp!=0) {
289          temp->setToZero();
290          return;
291        }
292      }
293      throw DataException("Error - Data can not be set to zero.");
294    }
295    
296  void  void
297  Data::copyWithMask(const Data& other,  Data::copyWithMask(const Data& other,
298                     const Data& mask)                     const Data& mask)
# Line 423  Data::tag() Line 397  Data::tag()
397  Data  Data
398  Data::oneOver() const  Data::oneOver() const
399  {  {
 #if defined DOPROF  
   profData->where++;  
 #endif  
400    return escript::unaryOp(*this,bind1st(divides<double>(),1.));    return escript::unaryOp(*this,bind1st(divides<double>(),1.));
401  }  }
402    
403  Data  Data
404  Data::wherePositive() const  Data::wherePositive() const
405  {  {
 #if defined DOPROF  
   profData->where++;  
 #endif  
406    return escript::unaryOp(*this,bind2nd(greater<double>(),0.0));    return escript::unaryOp(*this,bind2nd(greater<double>(),0.0));
407  }  }
408    
409  Data  Data
410  Data::whereNegative() const  Data::whereNegative() const
411  {  {
 #if defined DOPROF  
   profData->where++;  
 #endif  
412    return escript::unaryOp(*this,bind2nd(less<double>(),0.0));    return escript::unaryOp(*this,bind2nd(less<double>(),0.0));
413  }  }
414    
415  Data  Data
416  Data::whereNonNegative() const  Data::whereNonNegative() const
417  {  {
 #if defined DOPROF  
   profData->where++;  
 #endif  
418    return escript::unaryOp(*this,bind2nd(greater_equal<double>(),0.0));    return escript::unaryOp(*this,bind2nd(greater_equal<double>(),0.0));
419  }  }
420    
421  Data  Data
422  Data::whereNonPositive() const  Data::whereNonPositive() const
423  {  {
 #if defined DOPROF  
   profData->where++;  
 #endif  
424    return escript::unaryOp(*this,bind2nd(less_equal<double>(),0.0));    return escript::unaryOp(*this,bind2nd(less_equal<double>(),0.0));
425  }  }
426    
427  Data  Data
428  Data::whereZero(double tol) const  Data::whereZero(double tol) const
429  {  {
 #if defined DOPROF  
   profData->where++;  
 #endif  
430    Data dataAbs=abs();    Data dataAbs=abs();
431    return escript::unaryOp(dataAbs,bind2nd(less_equal<double>(),tol));    return escript::unaryOp(dataAbs,bind2nd(less_equal<double>(),tol));
432  }  }
# Line 478  Data::whereZero(double tol) const Line 434  Data::whereZero(double tol) const
434  Data  Data
435  Data::whereNonZero(double tol) const  Data::whereNonZero(double tol) const
436  {  {
 #if defined DOPROF  
   profData->where++;  
 #endif  
437    Data dataAbs=abs();    Data dataAbs=abs();
438    return escript::unaryOp(dataAbs,bind2nd(greater<double>(),tol));    return escript::unaryOp(dataAbs,bind2nd(greater<double>(),tol));
439  }  }
# Line 488  Data::whereNonZero(double tol) const Line 441  Data::whereNonZero(double tol) const
441  Data  Data
442  Data::interpolate(const FunctionSpace& functionspace) const  Data::interpolate(const FunctionSpace& functionspace) const
443  {  {
 #if defined DOPROF  
   profData->interpolate++;  
 #endif  
444    return Data(*this,functionspace);    return Data(*this,functionspace);
445  }  }
446    
# Line 512  Data::probeInterpolation(const FunctionS Line 462  Data::probeInterpolation(const FunctionS
462  Data  Data
463  Data::gradOn(const FunctionSpace& functionspace) const  Data::gradOn(const FunctionSpace& functionspace) const
464  {  {
 #if defined DOPROF  
   profData->grad++;  
 #endif  
465    if (functionspace.getDomain()!=getDomain())    if (functionspace.getDomain()!=getDomain())
466      throw DataException("Error - gradient cannot be calculated on different domains.");      throw DataException("Error - gradient cannot be calculated on different domains.");
467    DataArrayView::ShapeType grad_shape=getPointDataView().getShape();    DataArrayView::ShapeType grad_shape=getPointDataView().getShape();
# Line 550  Data::getDataPointShape() const Line 497  Data::getDataPointShape() const
497    
498    
499    
 void  
 Data::fillFromNumArray(const boost::python::numeric::array num_array)  
 {  
   if (isProtected()) {  
         throw DataException("Error - attempt to update protected Data object.");  
   }  
   //  
   // check rank  
   if (num_array.getrank()<getDataPointRank())  
       throw DataException("Rank of numarray does not match Data object rank");  
   
   //  
   // check shape of num_array  
   for (int i=0; i<getDataPointRank(); i++) {  
     if (extract<int>(num_array.getshape()[i+1])!=getDataPointShape()[i])  
        throw DataException("Shape of numarray does not match Data object rank");  
   }  
   
   //  
   // make sure data is expanded:  
   if (!isExpanded()) {  
     expand();  
   }  
   
   //  
   // and copy over  
   m_data->copyAll(num_array);  
 }  
   
 const  
 boost::python::numeric::array  
 Data::convertToNumArray()  
 {  
   //  
   // determine the total number of data points  
   int numSamples = getNumSamples();  
   int numDataPointsPerSample = getNumDataPointsPerSample();  
   int numDataPoints = numSamples * numDataPointsPerSample;  
   
   //  
   // determine the rank and shape of each data point  
   int dataPointRank = getDataPointRank();  
   DataArrayView::ShapeType dataPointShape = getDataPointShape();  
   
   //  
   // create the numeric array to be returned  
   boost::python::numeric::array numArray(0.0);  
   
   //  
   // the rank of the returned numeric array will be the rank of  
   // the data points, plus one. Where the rank of the array is n,  
   // the last n-1 dimensions will be equal to the shape of the  
   // data points, whilst the first dimension will be equal to the  
   // total number of data points. Thus the array will consist of  
   // a serial vector of the data points.  
   int arrayRank = dataPointRank + 1;  
   DataArrayView::ShapeType arrayShape;  
   arrayShape.push_back(numDataPoints);  
   for (int d=0; d<dataPointRank; d++) {  
      arrayShape.push_back(dataPointShape[d]);  
   }  
   
   //  
   // resize the numeric array to the shape just calculated  
   if (arrayRank==1) {  
     numArray.resize(arrayShape[0]);  
   }  
   if (arrayRank==2) {  
     numArray.resize(arrayShape[0],arrayShape[1]);  
   }  
   if (arrayRank==3) {  
     numArray.resize(arrayShape[0],arrayShape[1],arrayShape[2]);  
   }  
   if (arrayRank==4) {  
     numArray.resize(arrayShape[0],arrayShape[1],arrayShape[2],arrayShape[3]);  
   }  
   if (arrayRank==5) {  
     numArray.resize(arrayShape[0],arrayShape[1],arrayShape[2],arrayShape[3],arrayShape[4]);  
   }  
   
   //  
   // loop through each data point in turn, loading the values for that data point  
   // into the numeric array.  
   int dataPoint = 0;  
   for (int sampleNo = 0; sampleNo < numSamples; sampleNo++) {  
     for (int dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {  
       DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);  
       if (dataPointRank==0) {  
         numArray[dataPoint]=dataPointView();  
       }  
       if (dataPointRank==1) {  
         for (int i=0; i<dataPointShape[0]; i++) {  
           numArray[make_tuple(dataPoint,i)]=dataPointView(i);  
         }  
       }  
       if (dataPointRank==2) {  
         for (int i=0; i<dataPointShape[0]; i++) {  
           for (int j=0; j<dataPointShape[1]; j++) {  
             numArray[make_tuple(dataPoint,i,j)] = dataPointView(i,j);  
           }  
         }  
       }  
       if (dataPointRank==3) {  
         for (int i=0; i<dataPointShape[0]; i++) {  
           for (int j=0; j<dataPointShape[1]; j++) {  
             for (int k=0; k<dataPointShape[2]; k++) {  
               numArray[make_tuple(dataPoint,i,j,k)]=dataPointView(i,j,k);  
             }  
           }  
         }  
       }  
       if (dataPointRank==4) {  
         for (int i=0; i<dataPointShape[0]; i++) {  
           for (int j=0; j<dataPointShape[1]; j++) {  
             for (int k=0; k<dataPointShape[2]; k++) {  
               for (int l=0; l<dataPointShape[3]; l++) {  
                 numArray[make_tuple(dataPoint,i,j,k,l)]=dataPointView(i,j,k,l);  
               }  
             }  
           }  
         }  
       }  
       dataPoint++;  
     }  
   }  
   
   //  
   // return the loaded array  
   return numArray;  
 }  
   
   
500  const  const
501  boost::python::numeric::array  boost::python::numeric::array
502  Data:: getValueOfDataPoint(int dataPointNo)  Data:: getValueOfDataPoint(int dataPointNo)
# Line 773  Data:: getValueOfDataPoint(int dataPoint Line 588  Data:: getValueOfDataPoint(int dataPoint
588    
589  }  }
590  void  void
591  Data::setValueOfDataPointToArray(int dataPointNo, const boost::python::numeric::array num_array)  Data::setValueOfDataPointToPyObject(int dataPointNo, const boost::python::object& py_object)
592    {
593        // this will throw if the value cannot be represented
594        boost::python::numeric::array num_array(py_object);
595        setValueOfDataPointToArray(dataPointNo,num_array);
596    
597    
598    }
599    
600    void
601    Data::setValueOfDataPointToArray(int dataPointNo, const boost::python::numeric::array& num_array)
602  {  {
603    if (isProtected()) {    if (isProtected()) {
604          throw DataException("Error - attempt to update protected Data object.");          throw DataException("Error - attempt to update protected Data object.");
# Line 970  Data::integrate() const Line 795  Data::integrate() const
795    int rank = getDataPointRank();    int rank = getDataPointRank();
796    DataArrayView::ShapeType shape = getDataPointShape();    DataArrayView::ShapeType shape = getDataPointShape();
797    
 #if defined DOPROF  
   profData->integrate++;  
 #endif  
798    
799    //    //
800    // calculate the integral values    // calculate the integral values
# Line 1035  Data::integrate() const Line 857  Data::integrate() const
857  }  }
858    
859  Data  Data
 Data::erf() const  
 {  
 #if defined DOPROF  
   profData->unary++;  
 #endif  
   return escript::unaryOp(*this,(Data::UnaryDFunPtr)::erf);  
 }  
   
 Data  
860  Data::sin() const  Data::sin() const
861  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
862    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sin);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sin);
863  }  }
864    
865  Data  Data
866  Data::cos() const  Data::cos() const
867  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
868    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::cos);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::cos);
869  }  }
870    
871  Data  Data
872  Data::tan() const  Data::tan() const
873  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
874    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::tan);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::tan);
875  }  }
876    
877  Data  Data
878  Data::asin() const  Data::asin() const
879  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
880    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::asin);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::asin);
881  }  }
882    
883  Data  Data
884  Data::acos() const  Data::acos() const
885  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
886    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::acos);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::acos);
887  }  }
888    
889    
890  Data  Data
891  Data::atan() const  Data::atan() const
892  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
893    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::atan);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::atan);
894  }  }
895    
896  Data  Data
897  Data::sinh() const  Data::sinh() const
898  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
899    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sinh);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sinh);
900  }  }
901    
902  Data  Data
903  Data::cosh() const  Data::cosh() const
904  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
905    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::cosh);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::cosh);
906  }  }
907    
908  Data  Data
909  Data::tanh() const  Data::tanh() const
910  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
911    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::tanh);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::tanh);
912  }  }
913    
914    
915  Data  Data
916  Data::asinh() const  Data::erf() const
917  {  {
918  #if defined DOPROF  #ifdef _WIN32
919    profData->unary++;    throw DataException("Error - Data:: erf function is not supported on _WIN32 platforms.");
920    #else
921      return escript::unaryOp(*this,(Data::UnaryDFunPtr)::erf);
922  #endif  #endif
923    }
924    
925    Data
926    Data::asinh() const
927    {
928    #ifdef _WIN32
929      return escript::unaryOp(*this,escript::asinh_substitute);
930    #else
931    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::asinh);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::asinh);
932    #endif
933  }  }
934    
935  Data  Data
936  Data::acosh() const  Data::acosh() const
937  {  {
938  #if defined DOPROF  #ifdef _WIN32
939    profData->unary++;    return escript::unaryOp(*this,escript::acosh_substitute);
940  #endif  #else
941    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::acosh);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::acosh);
942    #endif
943  }  }
944    
945  Data  Data
946  Data::atanh() const  Data::atanh() const
947  {  {
948  #if defined DOPROF  #ifdef _WIN32
949    profData->unary++;    return escript::unaryOp(*this,escript::atanh_substitute);
950  #endif  #else
951    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::atanh);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::atanh);
952    #endif
953  }  }
954    
955  Data  Data
956  Data::log10() const  Data::log10() const
957  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
958    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::log10);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::log10);
959  }  }
960    
961  Data  Data
962  Data::log() const  Data::log() const
963  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
964    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::log);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::log);
965  }  }
966    
967  Data  Data
968  Data::sign() const  Data::sign() const
969  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
970    return escript::unaryOp(*this,escript::fsign);    return escript::unaryOp(*this,escript::fsign);
971  }  }
972    
973  Data  Data
974  Data::abs() const  Data::abs() const
975  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
976    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::fabs);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::fabs);
977  }  }
978    
979  Data  Data
980  Data::neg() const  Data::neg() const
981  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
982    return escript::unaryOp(*this,negate<double>());    return escript::unaryOp(*this,negate<double>());
983  }  }
984    
985  Data  Data
986  Data::pos() const  Data::pos() const
987  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
988    Data result;    Data result;
989    // perform a deep copy    // perform a deep copy
990    result.copy(*this);    result.copy(*this);
# Line 1211  Data::pos() const Line 994  Data::pos() const
994  Data  Data
995  Data::exp() const  Data::exp() const
996  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
997    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::exp);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::exp);
998  }  }
999    
1000  Data  Data
1001  Data::sqrt() const  Data::sqrt() const
1002  {  {
 #if defined DOPROF  
   profData->unary++;  
 #endif  
1003    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sqrt);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sqrt);
1004  }  }
1005    
# Line 1230  double Line 1007  double
1007  Data::Lsup() const  Data::Lsup() const
1008  {  {
1009    double localValue, globalValue;    double localValue, globalValue;
 #if defined DOPROF  
   profData->reduction1++;  
 #endif  
1010    //    //
1011    // set the initial absolute maximum value to zero    // set the initial absolute maximum value to zero
1012    
# Line 1250  double Line 1024  double
1024  Data::Linf() const  Data::Linf() const
1025  {  {
1026    double localValue, globalValue;    double localValue, globalValue;
 #if defined DOPROF  
   profData->reduction1++;  
 #endif  
1027    //    //
1028    // set the initial absolute minimum value to max double    // set the initial absolute minimum value to max double
1029    AbsMin abs_min_func;    AbsMin abs_min_func;
# Line 1270  double Line 1041  double
1041  Data::sup() const  Data::sup() const
1042  {  {
1043    double localValue, globalValue;    double localValue, globalValue;
 #if defined DOPROF  
   profData->reduction1++;  
 #endif  
1044    //    //
1045    // set the initial maximum value to min possible double    // set the initial maximum value to min possible double
1046    FMax fmax_func;    FMax fmax_func;
# Line 1289  double Line 1057  double
1057  Data::inf() const  Data::inf() const
1058  {  {
1059    double localValue, globalValue;    double localValue, globalValue;
 #if defined DOPROF  
   profData->reduction1++;  
 #endif  
1060    //    //
1061    // set the initial minimum value to max possible double    // set the initial minimum value to max possible double
1062    FMin fmin_func;    FMin fmin_func;
# Line 1309  Data::inf() const Line 1074  Data::inf() const
1074  Data  Data
1075  Data::maxval() const  Data::maxval() const
1076  {  {
 #if defined DOPROF  
   profData->reduction2++;  
 #endif  
1077    //    //
1078    // set the initial maximum value to min possible double    // set the initial maximum value to min possible double
1079    FMax fmax_func;    FMax fmax_func;
# Line 1321  Data::maxval() const Line 1083  Data::maxval() const
1083  Data  Data
1084  Data::minval() const  Data::minval() const
1085  {  {
 #if defined DOPROF  
   profData->reduction2++;  
 #endif  
1086    //    //
1087    // set the initial minimum value to max possible double    // set the initial minimum value to max possible double
1088    FMin fmin_func;    FMin fmin_func;
# Line 1334  Data Line 1093  Data
1093  Data::swapaxes(const int axis0, const int axis1) const  Data::swapaxes(const int axis0, const int axis1) const
1094  {  {
1095       int axis0_tmp,axis1_tmp;       int axis0_tmp,axis1_tmp;
      #if defined DOPROF  
      profData->unary++;  
      #endif  
1096       DataArrayView::ShapeType s=getDataPointShape();       DataArrayView::ShapeType s=getDataPointShape();
1097       DataArrayView::ShapeType ev_shape;       DataArrayView::ShapeType ev_shape;
1098       // 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]
# Line 1380  Data::swapaxes(const int axis0, const in Line 1136  Data::swapaxes(const int axis0, const in
1136  Data  Data
1137  Data::symmetric() const  Data::symmetric() const
1138  {  {
      #if defined DOPROF  
         profData->unary++;  
      #endif  
1139       // check input       // check input
1140       DataArrayView::ShapeType s=getDataPointShape();       DataArrayView::ShapeType s=getDataPointShape();
1141       if (getDataPointRank()==2) {       if (getDataPointRank()==2) {
# Line 1405  Data::symmetric() const Line 1158  Data::symmetric() const
1158  Data  Data
1159  Data::nonsymmetric() const  Data::nonsymmetric() const
1160  {  {
      #if defined DOPROF  
         profData->unary++;  
      #endif  
1161       // check input       // check input
1162       DataArrayView::ShapeType s=getDataPointShape();       DataArrayView::ShapeType s=getDataPointShape();
1163       if (getDataPointRank()==2) {       if (getDataPointRank()==2) {
# Line 1442  Data::nonsymmetric() const Line 1192  Data::nonsymmetric() const
1192  Data  Data
1193  Data::trace(int axis_offset) const  Data::trace(int axis_offset) const
1194  {  {
      #if defined DOPROF  
         profData->unary++;  
      #endif  
1195       DataArrayView::ShapeType s=getDataPointShape();       DataArrayView::ShapeType s=getDataPointShape();
1196       if (getDataPointRank()==2) {       if (getDataPointRank()==2) {
1197          DataArrayView::ShapeType ev_shape;          DataArrayView::ShapeType ev_shape;
# Line 1495  Data::trace(int axis_offset) const Line 1242  Data::trace(int axis_offset) const
1242  Data  Data
1243  Data::transpose(int axis_offset) const  Data::transpose(int axis_offset) const
1244  {  {
      #if defined DOPROF  
      profData->unary++;  
      #endif  
1245       DataArrayView::ShapeType s=getDataPointShape();       DataArrayView::ShapeType s=getDataPointShape();
1246       DataArrayView::ShapeType ev_shape;       DataArrayView::ShapeType ev_shape;
1247       // 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]
# Line 1519  Data::transpose(int axis_offset) const Line 1263  Data::transpose(int axis_offset) const
1263  Data  Data
1264  Data::eigenvalues() const  Data::eigenvalues() const
1265  {  {
      #if defined DOPROF  
         profData->unary++;  
      #endif  
1266       // check input       // check input
1267       DataArrayView::ShapeType s=getDataPointShape();       DataArrayView::ShapeType s=getDataPointShape();
1268       if (getDataPointRank()!=2)       if (getDataPointRank()!=2)
# Line 1539  Data::eigenvalues() const Line 1280  Data::eigenvalues() const
1280  const boost::python::tuple  const boost::python::tuple
1281  Data::eigenvalues_and_eigenvectors(const double tol) const  Data::eigenvalues_and_eigenvectors(const double tol) const
1282  {  {
      #if defined DOPROF  
         profData->unary++;  
      #endif  
1283       DataArrayView::ShapeType s=getDataPointShape();       DataArrayView::ShapeType s=getDataPointShape();
1284       if (getDataPointRank()!=2)       if (getDataPointRank()!=2)
1285          throw DataException("Error - Data::eigenvalues and eigenvectors can only be calculated for rank 2 object.");          throw DataException("Error - Data::eigenvalues and eigenvectors can only be calculated for rank 2 object.");
# Line 1955  Data::getItem(const boost::python::objec Line 1693  Data::getItem(const boost::python::objec
1693  Data  Data
1694  Data::getSlice(const DataArrayView::RegionType& region) const  Data::getSlice(const DataArrayView::RegionType& region) const
1695  {  {
 #if defined DOPROF  
   profData->slicing++;  
 #endif  
1696    return Data(*this,region);    return Data(*this,region);
1697  }  }
1698    
# Line 1999  Data::setSlice(const Data& value, Line 1734  Data::setSlice(const Data& value,
1734    if (isProtected()) {    if (isProtected()) {
1735          throw DataException("Error - attempt to update protected Data object.");          throw DataException("Error - attempt to update protected Data object.");
1736    }    }
 #if defined DOPROF  
   profData->slicing++;  
 #endif  
1737    Data tempValue(value);    Data tempValue(value);
1738    typeMatchLeft(tempValue);    typeMatchLeft(tempValue);
1739    typeMatchRight(tempValue);    typeMatchRight(tempValue);
# Line 2036  Data::typeMatchRight(const Data& right) Line 1768  Data::typeMatchRight(const Data& right)
1768    }    }
1769  }  }
1770    
1771  /* TODO */  void
1772  /* global reduction */  Data::setTaggedValueByName(std::string name,
1773                               const boost::python::object& value)
1774    {
1775         if (getFunctionSpace().getDomain().isValidTagName(name)) {
1776            int tagKey=getFunctionSpace().getDomain().getTag(name);
1777            setTaggedValue(tagKey,value);
1778         }
1779    }
1780  void  void
1781  Data::setTaggedValue(int tagKey,  Data::setTaggedValue(int tagKey,
1782                       const boost::python::object& value)                       const boost::python::object& value)
# Line 2062  Data::setTaggedValue(int tagKey, Line 1801  Data::setTaggedValue(int tagKey,
1801    m_data->setTaggedValue(tagKey,valueDataArray.getView());    m_data->setTaggedValue(tagKey,valueDataArray.getView());
1802  }  }
1803    
 /* TODO */  
 /* global reduction */  
1804  void  void
1805  Data::setTaggedValueFromCPP(int tagKey,  Data::setTaggedValueFromCPP(int tagKey,
1806                              const DataArrayView& value)                              const DataArrayView& value)
# Line 2084  Data::setTaggedValueFromCPP(int tagKey, Line 1821  Data::setTaggedValueFromCPP(int tagKey,
1821    m_data->setTaggedValue(tagKey,value);    m_data->setTaggedValue(tagKey,value);
1822  }  }
1823    
 /* TODO */  
 /* global reduction */  
1824  int  int
1825  Data::getTagNumber(int dpno)  Data::getTagNumber(int dpno)
1826  {  {
# Line 2442  escript::C_GeneralTensorProduct(Data& ar Line 2177  escript::C_GeneralTensorProduct(Data& ar
2177    // General tensor product: res(SL x SR) = arg_0(SL x SM) * arg_1(SM x SR)    // General tensor product: res(SL x SR) = arg_0(SL x SM) * arg_1(SM x SR)
2178    // SM is the product of the last axis_offset entries in arg_0.getShape().    // SM is the product of the last axis_offset entries in arg_0.getShape().
2179    
   #if defined DOPROF  
     // profData->binary++;  
   #endif  
2180    
2181    // Interpolate if necessary and find an appropriate function space    // Interpolate if necessary and find an appropriate function space
2182    Data arg_0_Z, arg_1_Z;    Data arg_0_Z, arg_1_Z;

Legend:
Removed from v.964  
changed lines
  Added in v.1118

  ViewVC Help
Powered by ViewVC 1.1.26