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

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

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

revision 147 by jgs, Fri Aug 12 01:45:47 2005 UTC revision 153 by jgs, Tue Oct 25 01:51:20 2005 UTC
# Line 25  Line 25 
25  #include <functional>  #include <functional>
26  #include <math.h>  #include <math.h>
27    
28    #include <boost/python/dict.hpp>
29  #include <boost/python/str.hpp>  #include <boost/python/str.hpp>
30  #include <boost/python/extract.hpp>  #include <boost/python/extract.hpp>
31  #include <boost/python/long.hpp>  #include <boost/python/long.hpp>
# Line 45  using namespace boost::python; Line 46  using namespace boost::python;
46  using namespace boost;  using namespace boost;
47  using namespace escript;  using namespace escript;
48    
49    #if defined DOPROF
50  //  //
51  // global table of profiling data for all Data objects  // global table of profiling data for all Data objects
52  DataProf dataProfTable;  DataProf dataProfTable;
53    #endif
54    
55  Data::Data()  Data::Data()
56  {  {
# Line 56  Data::Data() Line 59  Data::Data()
59    DataAbstract* temp=new DataEmpty();    DataAbstract* temp=new DataEmpty();
60    shared_ptr<DataAbstract> temp_data(temp);    shared_ptr<DataAbstract> temp_data(temp);
61    m_data=temp_data;    m_data=temp_data;
62    #if defined DOPROF
63    // create entry in global profiling table for this object    // create entry in global profiling table for this object
64    profData = dataProfTable.newData();    profData = dataProfTable.newData();
65    #endif
66  }  }
67    
68  Data::Data(double value,  Data::Data(double value,
# Line 71  Data::Data(double value, Line 76  Data::Data(double value,
76    }    }
77    DataArray temp(dataPointShape,value);    DataArray temp(dataPointShape,value);
78    initialise(temp.getView(),what,expanded);    initialise(temp.getView(),what,expanded);
79    #if defined DOPROF
80    // create entry in global profiling table for this object    // create entry in global profiling table for this object
81    profData = dataProfTable.newData();    profData = dataProfTable.newData();
82    #endif
83  }  }
84    
85  Data::Data(double value,  Data::Data(double value,
# Line 83  Data::Data(double value, Line 90  Data::Data(double value,
90    DataArray temp(dataPointShape,value);    DataArray temp(dataPointShape,value);
91    pair<int,int> dataShape=what.getDataShape();    pair<int,int> dataShape=what.getDataShape();
92    initialise(temp.getView(),what,expanded);    initialise(temp.getView(),what,expanded);
93    #if defined DOPROF
94    // create entry in global profiling table for this object    // create entry in global profiling table for this object
95    profData = dataProfTable.newData();    profData = dataProfTable.newData();
96    #endif
97  }  }
98    
99  Data::Data(const Data& inData)  Data::Data(const Data& inData)
100  {  {
101    m_data=inData.m_data;    m_data=inData.m_data;
102    #if defined DOPROF
103    // create entry in global profiling table for this object    // create entry in global profiling table for this object
104    profData = dataProfTable.newData();    profData = dataProfTable.newData();
105    #endif
106  }  }
107    
108  Data::Data(const Data& inData,  Data::Data(const Data& inData,
# Line 102  Data::Data(const Data& inData, Line 113  Data::Data(const Data& inData,
113    DataAbstract* tmp = inData.m_data->getSlice(region);    DataAbstract* tmp = inData.m_data->getSlice(region);
114    shared_ptr<DataAbstract> temp_data(tmp);    shared_ptr<DataAbstract> temp_data(tmp);
115    m_data=temp_data;    m_data=temp_data;
116    #if defined DOPROF
117    // create entry in global profiling table for this object    // create entry in global profiling table for this object
118    profData = dataProfTable.newData();    profData = dataProfTable.newData();
119    #endif
120  }  }
121    
122  Data::Data(const Data& inData,  Data::Data(const Data& inData,
# Line 125  Data::Data(const Data& inData, Line 138  Data::Data(const Data& inData,
138      }      }
139      m_data=tmp.m_data;      m_data=tmp.m_data;
140    }    }
141    #if defined DOPROF
142    // create entry in global profiling table for this object    // create entry in global profiling table for this object
143    profData = dataProfTable.newData();    profData = dataProfTable.newData();
144    #endif
145  }  }
146    
147  Data::Data(const DataTagged::TagListType& tagKeys,  Data::Data(const DataTagged::TagListType& tagKeys,
# Line 141  Data::Data(const DataTagged::TagListType Line 156  Data::Data(const DataTagged::TagListType
156    if (expanded) {    if (expanded) {
157      expand();      expand();
158    }    }
159    #if defined DOPROF
160    // create entry in global profiling table for this object    // create entry in global profiling table for this object
161    profData = dataProfTable.newData();    profData = dataProfTable.newData();
162    #endif
163  }  }
164    
165  Data::Data(const numeric::array& value,  Data::Data(const numeric::array& value,
# Line 150  Data::Data(const numeric::array& value, Line 167  Data::Data(const numeric::array& value,
167             bool expanded)             bool expanded)
168  {  {
169    initialise(value,what,expanded);    initialise(value,what,expanded);
170    #if defined DOPROF
171    // create entry in global profiling table for this object    // create entry in global profiling table for this object
172    profData = dataProfTable.newData();    profData = dataProfTable.newData();
173    #endif
174  }  }
175    
176  Data::Data(const DataArrayView& value,  Data::Data(const DataArrayView& value,
# Line 159  Data::Data(const DataArrayView& value, Line 178  Data::Data(const DataArrayView& value,
178             bool expanded)             bool expanded)
179  {  {
180    initialise(value,what,expanded);    initialise(value,what,expanded);
181    #if defined DOPROF
182    // create entry in global profiling table for this object    // create entry in global profiling table for this object
183    profData = dataProfTable.newData();    profData = dataProfTable.newData();
184    #endif
185  }  }
186    
187  Data::Data(const object& value,  Data::Data(const object& value,
# Line 169  Data::Data(const object& value, Line 190  Data::Data(const object& value,
190  {  {
191    numeric::array asNumArray(value);    numeric::array asNumArray(value);
192    initialise(asNumArray,what,expanded);    initialise(asNumArray,what,expanded);
193    #if defined DOPROF
194    // create entry in global profiling table for this object    // create entry in global profiling table for this object
195    profData = dataProfTable.newData();    profData = dataProfTable.newData();
196    #endif
197  }  }
198    
199  Data::Data(const object& value,  Data::Data(const object& value,
# Line 191  Data::Data(const object& value, Line 214  Data::Data(const object& value,
214      // Create a DataConstant with the same sample shape as other      // Create a DataConstant with the same sample shape as other
215      initialise(temp.getView(),other.getFunctionSpace(),false);      initialise(temp.getView(),other.getFunctionSpace(),false);
216    }    }
217    #if defined DOPROF
218    // create entry in global profiling table for this object    // create entry in global profiling table for this object
219    profData = dataProfTable.newData();    profData = dataProfTable.newData();
220    #endif
221    }
222    
223    Data::~Data()
224    {
225    
226  }  }
227    
228  escriptDataC  escriptDataC
# Line 379  Data::reshapeDataPoint(const DataArrayVi Line 409  Data::reshapeDataPoint(const DataArrayVi
409  Data  Data
410  Data::wherePositive() const  Data::wherePositive() const
411  {  {
412    #if defined DOPROF
413    profData->where++;    profData->where++;
414    #endif
415    return escript::unaryOp(*this,bind2nd(greater<double>(),0.0));    return escript::unaryOp(*this,bind2nd(greater<double>(),0.0));
416  }  }
417    
418  Data  Data
419  Data::whereNegative() const  Data::whereNegative() const
420  {  {
421    #if defined DOPROF
422    profData->where++;    profData->where++;
423    #endif
424    return escript::unaryOp(*this,bind2nd(less<double>(),0.0));    return escript::unaryOp(*this,bind2nd(less<double>(),0.0));
425  }  }
426    
427  Data  Data
428  Data::whereNonNegative() const  Data::whereNonNegative() const
429  {  {
430    #if defined DOPROF
431    profData->where++;    profData->where++;
432    #endif
433    return escript::unaryOp(*this,bind2nd(greater_equal<double>(),0.0));    return escript::unaryOp(*this,bind2nd(greater_equal<double>(),0.0));
434  }  }
435    
436  Data  Data
437  Data::whereNonPositive() const  Data::whereNonPositive() const
438  {  {
439    #if defined DOPROF
440    profData->where++;    profData->where++;
441    #endif
442    return escript::unaryOp(*this,bind2nd(less_equal<double>(),0.0));    return escript::unaryOp(*this,bind2nd(less_equal<double>(),0.0));
443  }  }
444    
445  Data  Data
446  Data::whereZero() const  Data::whereZero() const
447  {  {
448    #if defined DOPROF
449    profData->where++;    profData->where++;
450    #endif
451    return escript::unaryOp(*this,bind2nd(equal_to<double>(),0.0));    return escript::unaryOp(*this,bind2nd(equal_to<double>(),0.0));
452  }  }
453    
454  Data  Data
455  Data::whereNonZero() const  Data::whereNonZero() const
456  {  {
457    #if defined DOPROF
458    profData->where++;    profData->where++;
459    #endif
460    return escript::unaryOp(*this,bind2nd(not_equal_to<double>(),0.0));    return escript::unaryOp(*this,bind2nd(not_equal_to<double>(),0.0));
461  }  }
462    
463  Data  Data
464  Data::interpolate(const FunctionSpace& functionspace) const  Data::interpolate(const FunctionSpace& functionspace) const
465  {  {
466    #if defined DOPROF
467    profData->interpolate++;    profData->interpolate++;
468    #endif
469    return Data(*this,functionspace);    return Data(*this,functionspace);
470  }  }
471    
# Line 443  Data::probeInterpolation(const FunctionS Line 487  Data::probeInterpolation(const FunctionS
487  Data  Data
488  Data::gradOn(const FunctionSpace& functionspace) const  Data::gradOn(const FunctionSpace& functionspace) const
489  {  {
490    #if defined DOPROF
491    profData->grad++;    profData->grad++;
492    #endif
493    if (functionspace.getDomain()!=getDomain())    if (functionspace.getDomain()!=getDomain())
494      throw DataException("Error - gradient cannot be calculated on different domains.");      throw DataException("Error - gradient cannot be calculated on different domains.");
495    DataArrayView::ShapeType grad_shape=getPointDataView().getShape();    DataArrayView::ShapeType grad_shape=getPointDataView().getShape();
# Line 481  void Line 527  void
527  Data::fillFromNumArray(const boost::python::numeric::array num_array)  Data::fillFromNumArray(const boost::python::numeric::array num_array)
528  {  {
529    //    //
530    // check rank:    // check rank
531    if (num_array.getrank()<getDataPointRank())    if (num_array.getrank()<getDataPointRank())
532        throw DataException("Rank of numarray does not match Data object rank");        throw DataException("Rank of numarray does not match Data object rank");
533    
534    //    //
535    // check rank of num_array    // check shape of num_array
536    for (int i=0; i<getDataPointRank(); i++) {    for (int i=0; i<getDataPointRank(); i++) {
537      if (extract<int>(num_array.getshape()[i+1])!=getDataPointShape()[i])      if (extract<int>(num_array.getshape()[i+1])!=getDataPointShape()[i])
538         throw DataException("Shape of numarray does not match Data object rank");         throw DataException("Shape of numarray does not match Data object rank");
539    }    }
   //  
   // make sure data is expanded:  
   if (! isExpanded()) expand();  
   //  
   // and copy over:  
   m_data->copyAll(num_array);  
   //  
   // 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]);  
   // }  
540    
541    //    //
542    // loop through each data point in turn, loading the values for that data point    // make sure data is expanded:
543    // into the numeric array.    if (!isExpanded()) {
544    // int dataPoint = 0;      expand();
545    // for (int sampleNo = 0; sampleNo < numSamples; sampleNo++) {    }
   //   for (int dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {  
   //     DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);  
   //     if (dataPointRank==0) {  
   //       dataPointView()=numArray[dataPoint];  
   //     }  
   //     if (dataPointRank==1) {  
   //       for (int i=0; i<dataPointShape[0]; i++) {  
   //         dataPointView(i)=numArray[dataPoint][i];  
   //       }  
   //     }  
   //     if (dataPointRank==2) {  
   //       for (int i=0; i<dataPointShape[0]; i++) {  
   //         for (int j=0; j<dataPointShape[1]; j++) {  
   //           numArray[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[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[dataPoint][i][j][k][l]=dataPointView(i,j,k,l);  
   //             }  
   //           }  
   //         }  
   //       }  
   //     }  
   //     dataPoint++;  
   //   }  
   // }  
546    
547    //    //
548    // return the loaded array    // and copy over
549    // return numArray;    m_data->copyAll(num_array);
   
550  }  }
551    
552  const  const
# Line 885  Data::integrate() const Line 854  Data::integrate() const
854    int rank = getDataPointRank();    int rank = getDataPointRank();
855    DataArrayView::ShapeType shape = getDataPointShape();    DataArrayView::ShapeType shape = getDataPointShape();
856    
857    #if defined DOPROF
858    profData->integrate++;    profData->integrate++;
859    #endif
860    
861    //    //
862    // calculate the integral values    // calculate the integral values
# Line 950  Data::integrate() const Line 921  Data::integrate() const
921  Data  Data
922  Data::sin() const  Data::sin() const
923  {  {
924    #if defined DOPROF
925    profData->unary++;    profData->unary++;
926    #endif
927    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sin);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sin);
928  }  }
929    
930  Data  Data
931  Data::cos() const  Data::cos() const
932  {  {
933    #if defined DOPROF
934    profData->unary++;    profData->unary++;
935    #endif
936    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::cos);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::cos);
937  }  }
938    
939  Data  Data
940  Data::tan() const  Data::tan() const
941  {  {
942    #if defined DOPROF
943    profData->unary++;    profData->unary++;
944    #endif
945    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::tan);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::tan);
946  }  }
947    
948  Data  Data
949    Data::asin() const
950    {
951    #if defined DOPROF
952      profData->unary++;
953    #endif
954      return escript::unaryOp(*this,(Data::UnaryDFunPtr)::asin);
955    }
956    
957    Data
958    Data::acos() const
959    {
960    #if defined DOPROF
961      profData->unary++;
962    #endif
963      return escript::unaryOp(*this,(Data::UnaryDFunPtr)::acos);
964    }
965    
966    Data
967    Data::atan() const
968    {
969    #if defined DOPROF
970      profData->unary++;
971    #endif
972      return escript::unaryOp(*this,(Data::UnaryDFunPtr)::atan);
973    }
974    
975    Data
976    Data::sinh() const
977    {
978    #if defined DOPROF
979      profData->unary++;
980    #endif
981      return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sinh);
982    }
983    
984    Data
985    Data::cosh() const
986    {
987    #if defined DOPROF
988      profData->unary++;
989    #endif
990      return escript::unaryOp(*this,(Data::UnaryDFunPtr)::cosh);
991    }
992    
993    Data
994    Data::tanh() const
995    {
996    #if defined DOPROF
997      profData->unary++;
998    #endif
999      return escript::unaryOp(*this,(Data::UnaryDFunPtr)::tanh);
1000    }
1001    
1002    Data
1003    Data::asinh() const
1004    {
1005    #if defined DOPROF
1006      profData->unary++;
1007    #endif
1008      return escript::unaryOp(*this,(Data::UnaryDFunPtr)::asinh);
1009    }
1010    
1011    Data
1012    Data::acosh() const
1013    {
1014    #if defined DOPROF
1015      profData->unary++;
1016    #endif
1017      return escript::unaryOp(*this,(Data::UnaryDFunPtr)::acosh);
1018    }
1019    
1020    Data
1021    Data::atanh() const
1022    {
1023    #if defined DOPROF
1024      profData->unary++;
1025    #endif
1026      return escript::unaryOp(*this,(Data::UnaryDFunPtr)::atanh);
1027    }
1028    
1029    Data
1030  Data::log() const  Data::log() const
1031  {  {
1032    #if defined DOPROF
1033    profData->unary++;    profData->unary++;
1034    #endif
1035    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::log10);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::log10);
1036  }  }
1037    
1038  Data  Data
1039  Data::ln() const  Data::ln() const
1040  {  {
1041    #if defined DOPROF
1042    profData->unary++;    profData->unary++;
1043    #endif
1044    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::log);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::log);
1045  }  }
1046    
1047  Data  Data
1048  Data::sign() const  Data::sign() const
1049  {  {
1050    #if defined DOPROF
1051    profData->unary++;    profData->unary++;
1052    #endif
1053    return escript::unaryOp(*this,escript::fsign);    return escript::unaryOp(*this,escript::fsign);
1054  }  }
1055    
1056  Data  Data
1057  Data::abs() const  Data::abs() const
1058  {  {
1059    #if defined DOPROF
1060    profData->unary++;    profData->unary++;
1061    #endif
1062    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::fabs);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::fabs);
1063  }  }
1064    
1065  Data  Data
1066  Data::neg() const  Data::neg() const
1067  {  {
1068    #if defined DOPROF
1069    profData->unary++;    profData->unary++;
1070    #endif
1071    return escript::unaryOp(*this,negate<double>());    return escript::unaryOp(*this,negate<double>());
1072  }  }
1073    
1074  Data  Data
1075  Data::pos() const  Data::pos() const
1076  {  {
1077    #if defined DOPROF
1078    profData->unary++;    profData->unary++;
1079    return (*this);  #endif
1080      Data result;
1081      // perform a deep copy
1082      result.copy(*this);
1083      return result;
1084  }  }
1085    
1086  Data  Data
1087  Data::exp() const  Data::exp() const
1088  {  {
1089    #if defined DOPROF
1090    profData->unary++;    profData->unary++;
1091    #endif
1092    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::exp);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::exp);
1093  }  }
1094    
1095  Data  Data
1096  Data::sqrt() const  Data::sqrt() const
1097  {  {
1098    #if defined DOPROF
1099    profData->unary++;    profData->unary++;
1100    #endif
1101    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sqrt);    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sqrt);
1102  }  }
1103    
1104  double  double
1105  Data::Lsup() const  Data::Lsup() const
1106  {  {
1107    #if defined DOPROF
1108    profData->reduction1++;    profData->reduction1++;
1109    #endif
1110    //    //
1111    // set the initial absolute maximum value to zero    // set the initial absolute maximum value to zero
1112    AbsMax abs_max_func;    AbsMax abs_max_func;
# Line 1037  Data::Lsup() const Line 1116  Data::Lsup() const
1116  double  double
1117  Data::Linf() const  Data::Linf() const
1118  {  {
1119    #if defined DOPROF
1120    profData->reduction1++;    profData->reduction1++;
1121    #endif
1122    //    //
1123    // set the initial absolute minimum value to max double    // set the initial absolute minimum value to max double
1124    AbsMin abs_min_func;    AbsMin abs_min_func;
# Line 1047  Data::Linf() const Line 1128  Data::Linf() const
1128  double  double
1129  Data::sup() const  Data::sup() const
1130  {  {
1131    #if defined DOPROF
1132    profData->reduction1++;    profData->reduction1++;
1133    #endif
1134    //    //
1135    // set the initial maximum value to min possible double    // set the initial maximum value to min possible double
1136    FMax fmax_func;    FMax fmax_func;
# Line 1057  Data::sup() const Line 1140  Data::sup() const
1140  double  double
1141  Data::inf() const  Data::inf() const
1142  {  {
1143    #if defined DOPROF
1144    profData->reduction1++;    profData->reduction1++;
1145    #endif
1146    //    //
1147    // set the initial minimum value to max possible double    // set the initial minimum value to max possible double
1148    FMin fmin_func;    FMin fmin_func;
# Line 1067  Data::inf() const Line 1152  Data::inf() const
1152  Data  Data
1153  Data::maxval() const  Data::maxval() const
1154  {  {
1155    #if defined DOPROF
1156    profData->reduction2++;    profData->reduction2++;
1157    #endif
1158    //    //
1159    // set the initial maximum value to min possible double    // set the initial maximum value to min possible double
1160    FMax fmax_func;    FMax fmax_func;
# Line 1077  Data::maxval() const Line 1164  Data::maxval() const
1164  Data  Data
1165  Data::minval() const  Data::minval() const
1166  {  {
1167    #if defined DOPROF
1168    profData->reduction2++;    profData->reduction2++;
1169    #endif
1170    //    //
1171    // set the initial minimum value to max possible double    // set the initial minimum value to max possible double
1172    FMin fmin_func;    FMin fmin_func;
# Line 1087  Data::minval() const Line 1176  Data::minval() const
1176  Data  Data
1177  Data::length() const  Data::length() const
1178  {  {
1179    #if defined DOPROF
1180    profData->reduction2++;    profData->reduction2++;
1181    #endif
1182    Length len_func;    Length len_func;
1183    return dp_algorithm(len_func,0);    return dp_algorithm(len_func,0);
1184  }  }
# Line 1095  Data::length() const Line 1186  Data::length() const
1186  Data  Data
1187  Data::trace() const  Data::trace() const
1188  {  {
1189    #if defined DOPROF
1190    profData->reduction2++;    profData->reduction2++;
1191    #endif
1192    Trace trace_func;    Trace trace_func;
1193    return dp_algorithm(trace_func,0);    return dp_algorithm(trace_func,0);
1194  }  }
# Line 1103  Data::trace() const Line 1196  Data::trace() const
1196  Data  Data
1197  Data::transpose(int axis) const  Data::transpose(int axis) const
1198  {  {
1199    #if defined DOPROF
1200    profData->reduction2++;    profData->reduction2++;
1201    #endif
1202    // not implemented    // not implemented
1203    throw DataException("Error - Data::transpose not implemented yet.");    throw DataException("Error - Data::transpose not implemented yet.");
1204    return Data();    return Data();
# Line 1112  Data::transpose(int axis) const Line 1207  Data::transpose(int axis) const
1207  const boost::python::tuple  const boost::python::tuple
1208  Data::mindp() const  Data::mindp() const
1209  {  {
1210      // NB: calc_mindp had to be split off from mindp as boost::make_tuple causes an
1211      // abort (for unknown reasons) if there are openmp directives with it in the
1212      // surrounding function
1213    
1214      int SampleNo;
1215      int DataPointNo;
1216    
1217      calc_mindp(SampleNo,DataPointNo);
1218    
1219      return make_tuple(SampleNo,DataPointNo);
1220    }
1221    
1222    void
1223    Data::calc_mindp(int& SampleNo,
1224                     int& DataPointNo) const
1225    {
1226      int i,j;
1227      int lowi=0,lowj=0;
1228      double min=numeric_limits<double>::max();
1229    
1230    Data temp=minval();    Data temp=minval();
1231    
1232    int numSamples=temp.getNumSamples();    int numSamples=temp.getNumSamples();
1233    int numDPPSample=temp.getNumDataPointsPerSample();    int numDPPSample=temp.getNumDataPointsPerSample();
1234    
1235    int i,j,lowi=0,lowj=0;    double next,local_min;
1236    double min=numeric_limits<double>::max();    int local_lowi,local_lowj;
1237    
1238    for (i=0; i<numSamples; i++) {    #pragma omp parallel private(next,local_min,local_lowi,local_lowj)
1239      for (j=0; j<numDPPSample; j++) {    {
1240        double next=temp.getDataPoint(i,j)();      local_min=min;
1241        if (next<min) {      #pragma omp for private(i,j) schedule(static)
1242          min=next;      for (i=0; i<numSamples; i++) {
1243          lowi=i;        for (j=0; j<numDPPSample; j++) {
1244          lowj=j;          next=temp.getDataPoint(i,j)();
1245            if (next<local_min) {
1246              local_min=next;
1247              local_lowi=i;
1248              local_lowj=j;
1249            }
1250        }        }
1251      }      }
1252        #pragma omp critical
1253        if (local_min<min) {
1254          min=local_min;
1255          lowi=local_lowi;
1256          lowj=local_lowj;
1257        }
1258    }    }
1259    
1260    return make_tuple(lowi,lowj);    SampleNo = lowi;
1261      DataPointNo = lowj;
1262  }  }
1263    
1264  void  void
1265  Data::saveDX(std::string fileName) const  Data::saveDX(std::string fileName) const
1266  {  {
1267    getDomain().saveDX(fileName,*this);    boost::python::dict args;
1268      args["data"]=boost::python::object(this);
1269      getDomain().saveDX(fileName,args);
1270    return;    return;
1271  }  }
1272    
1273  void  void
1274  Data::saveVTK(std::string fileName) const  Data::saveVTK(std::string fileName) const
1275  {  {
1276    getDomain().saveVTK(fileName,*this);    boost::python::dict args;
1277      args["data"]=boost::python::object(this);
1278      getDomain().saveVTK(fileName,args);
1279    return;    return;
1280  }  }
1281    
1282  Data&  Data&
1283  Data::operator+=(const Data& right)  Data::operator+=(const Data& right)
1284  {  {
1285    #if defined DOPROF
1286    profData->binary++;    profData->binary++;
1287    #endif
1288    binaryOp(right,plus<double>());    binaryOp(right,plus<double>());
1289    return (*this);    return (*this);
1290  }  }
# Line 1159  Data::operator+=(const Data& right) Line 1292  Data::operator+=(const Data& right)
1292  Data&  Data&
1293  Data::operator+=(const boost::python::object& right)  Data::operator+=(const boost::python::object& right)
1294  {  {
1295    #if defined DOPROF
1296    profData->binary++;    profData->binary++;
1297    #endif
1298    binaryOp(right,plus<double>());    binaryOp(right,plus<double>());
1299    return (*this);    return (*this);
1300  }  }
# Line 1167  Data::operator+=(const boost::python::ob Line 1302  Data::operator+=(const boost::python::ob
1302  Data&  Data&
1303  Data::operator-=(const Data& right)  Data::operator-=(const Data& right)
1304  {  {
1305    #if defined DOPROF
1306    profData->binary++;    profData->binary++;
1307    #endif
1308    binaryOp(right,minus<double>());    binaryOp(right,minus<double>());
1309    return (*this);    return (*this);
1310  }  }
# Line 1175  Data::operator-=(const Data& right) Line 1312  Data::operator-=(const Data& right)
1312  Data&  Data&
1313  Data::operator-=(const boost::python::object& right)  Data::operator-=(const boost::python::object& right)
1314  {  {
1315    #if defined DOPROF
1316    profData->binary++;    profData->binary++;
1317    #endif
1318    binaryOp(right,minus<double>());    binaryOp(right,minus<double>());
1319    return (*this);    return (*this);
1320  }  }
# Line 1183  Data::operator-=(const boost::python::ob Line 1322  Data::operator-=(const boost::python::ob
1322  Data&  Data&
1323  Data::operator*=(const Data& right)  Data::operator*=(const Data& right)
1324  {  {
1325    #if defined DOPROF
1326    profData->binary++;    profData->binary++;
1327    #endif
1328    binaryOp(right,multiplies<double>());    binaryOp(right,multiplies<double>());
1329    return (*this);    return (*this);
1330  }  }
# Line 1191  Data::operator*=(const Data& right) Line 1332  Data::operator*=(const Data& right)
1332  Data&  Data&
1333  Data::operator*=(const boost::python::object& right)  Data::operator*=(const boost::python::object& right)
1334  {  {
1335    #if defined DOPROF
1336    profData->binary++;    profData->binary++;
1337    #endif
1338    binaryOp(right,multiplies<double>());    binaryOp(right,multiplies<double>());
1339    return (*this);    return (*this);
1340  }  }
# Line 1199  Data::operator*=(const boost::python::ob Line 1342  Data::operator*=(const boost::python::ob
1342  Data&  Data&
1343  Data::operator/=(const Data& right)  Data::operator/=(const Data& right)
1344  {  {
1345    #if defined DOPROF
1346    profData->binary++;    profData->binary++;
1347    #endif
1348    binaryOp(right,divides<double>());    binaryOp(right,divides<double>());
1349    return (*this);    return (*this);
1350  }  }
# Line 1207  Data::operator/=(const Data& right) Line 1352  Data::operator/=(const Data& right)
1352  Data&  Data&
1353  Data::operator/=(const boost::python::object& right)  Data::operator/=(const boost::python::object& right)
1354  {  {
1355    #if defined DOPROF
1356    profData->binary++;    profData->binary++;
1357    #endif
1358    binaryOp(right,divides<double>());    binaryOp(right,divides<double>());
1359    return (*this);    return (*this);
1360  }  }
# Line 1215  Data::operator/=(const boost::python::ob Line 1362  Data::operator/=(const boost::python::ob
1362  Data  Data
1363  Data::powO(const boost::python::object& right) const  Data::powO(const boost::python::object& right) const
1364  {  {
1365    #if defined DOPROF
1366    profData->binary++;    profData->binary++;
1367    #endif
1368    Data result;    Data result;
1369    result.copy(*this);    result.copy(*this);
1370    result.binaryOp(right,(Data::BinaryDFunPtr)::pow);    result.binaryOp(right,(Data::BinaryDFunPtr)::pow);
# Line 1225  Data::powO(const boost::python::object& Line 1374  Data::powO(const boost::python::object&
1374  Data  Data
1375  Data::powD(const Data& right) const  Data::powD(const Data& right) const
1376  {  {
1377    #if defined DOPROF
1378    profData->binary++;    profData->binary++;
1379    #endif
1380    Data result;    Data result;
1381    result.copy(*this);    result.copy(*this);
1382    result.binaryOp(right,(Data::BinaryDFunPtr)::pow);    result.binaryOp(right,(Data::BinaryDFunPtr)::pow);
# Line 1462  Data::getItem(const boost::python::objec Line 1613  Data::getItem(const boost::python::objec
1613  Data  Data
1614  Data::getSlice(const DataArrayView::RegionType& region) const  Data::getSlice(const DataArrayView::RegionType& region) const
1615  {  {
1616    #if defined DOPROF
1617    profData->slicing++;    profData->slicing++;
1618    #endif
1619    return Data(*this,region);    return Data(*this,region);
1620  }  }
1621    
# Line 1495  void Line 1648  void
1648  Data::setSlice(const Data& value,  Data::setSlice(const Data& value,
1649                 const DataArrayView::RegionType& region)                 const DataArrayView::RegionType& region)
1650  {  {
1651    #if defined DOPROF
1652    profData->slicing++;    profData->slicing++;
1653    #endif
1654    Data tempValue(value);    Data tempValue(value);
1655    typeMatchLeft(tempValue);    typeMatchLeft(tempValue);
1656    typeMatchRight(tempValue);    typeMatchRight(tempValue);
# Line 1568  Data::setTaggedValueFromCPP(int tagKey, Line 1723  Data::setTaggedValueFromCPP(int tagKey,
1723    m_data->setTaggedValue(tagKey,value);    m_data->setTaggedValue(tagKey,value);
1724  }  }
1725    
1726    int
1727    Data::getTagNumber(int dpno)
1728    {
1729      return m_data->getTagNumber(dpno);
1730    }
1731    
1732  void  void
1733  Data::setRefValue(int ref,  Data::setRefValue(int ref,
1734                    const boost::python::numeric::array& value)                    const boost::python::numeric::array& value)

Legend:
Removed from v.147  
changed lines
  Added in v.153

  ViewVC Help
Powered by ViewVC 1.1.26