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

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

  ViewVC Help
Powered by ViewVC 1.1.26