/[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 126 by jgs, Fri Jul 22 03:53:08 2005 UTC revision 148 by jgs, Tue Aug 23 01:24:31 2005 UTC
# Line 1007  Data Line 1007  Data
1007  Data::pos() const  Data::pos() const
1008  {  {
1009    profData->unary++;    profData->unary++;
1010    return (*this);    Data result;
1011      // perform a deep copy
1012      result.copy(*this);
1013      return result;
1014  }  }
1015    
1016  Data  Data
# Line 1030  Data::Lsup() const Line 1033  Data::Lsup() const
1033    profData->reduction1++;    profData->reduction1++;
1034    //    //
1035    // set the initial absolute maximum value to zero    // set the initial absolute maximum value to zero
1036    return algorithm(DataAlgorithmAdapter<AbsMax>(0));    AbsMax abs_max_func;
1037      return algorithm(abs_max_func,0);
1038  }  }
1039    
1040  double  double
# Line 1039  Data::Linf() const Line 1043  Data::Linf() const
1043    profData->reduction1++;    profData->reduction1++;
1044    //    //
1045    // set the initial absolute minimum value to max double    // set the initial absolute minimum value to max double
1046    return algorithm(DataAlgorithmAdapter<AbsMin>(numeric_limits<double>::max()));    AbsMin abs_min_func;
1047      return algorithm(abs_min_func,numeric_limits<double>::max());
1048  }  }
1049    
1050  double  double
# Line 1048  Data::sup() const Line 1053  Data::sup() const
1053    profData->reduction1++;    profData->reduction1++;
1054    //    //
1055    // set the initial maximum value to min possible double    // set the initial maximum value to min possible double
1056    return algorithm(DataAlgorithmAdapter<FMax>(numeric_limits<double>::max()*-1));    FMax fmax_func;
1057      return algorithm(fmax_func,numeric_limits<double>::max()*-1);
1058  }  }
1059    
1060  double  double
# Line 1057  Data::inf() const Line 1063  Data::inf() const
1063    profData->reduction1++;    profData->reduction1++;
1064    //    //
1065    // set the initial minimum value to max possible double    // set the initial minimum value to max possible double
1066    return algorithm(DataAlgorithmAdapter<FMin>(numeric_limits<double>::max()));    FMin fmin_func;
1067      return algorithm(fmin_func,numeric_limits<double>::max());
1068  }  }
1069    
1070  Data  Data
# Line 1066  Data::maxval() const Line 1073  Data::maxval() const
1073    profData->reduction2++;    profData->reduction2++;
1074    //    //
1075    // set the initial maximum value to min possible double    // set the initial maximum value to min possible double
1076    return dp_algorithm(DataAlgorithmAdapter<FMax>(numeric_limits<double>::max()*-1));    FMax fmax_func;
1077      return dp_algorithm(fmax_func,numeric_limits<double>::max()*-1);
1078  }  }
1079    
1080  Data  Data
# Line 1075  Data::minval() const Line 1083  Data::minval() const
1083    profData->reduction2++;    profData->reduction2++;
1084    //    //
1085    // set the initial minimum value to max possible double    // set the initial minimum value to max possible double
1086    return dp_algorithm(DataAlgorithmAdapter<FMin>(numeric_limits<double>::max()));    FMin fmin_func;
1087      return dp_algorithm(fmin_func,numeric_limits<double>::max());
1088  }  }
1089    
1090  Data  Data
1091  Data::length() const  Data::length() const
1092  {  {
1093    profData->reduction2++;    profData->reduction2++;
1094    return dp_algorithm(DataAlgorithmAdapter<Length>(0));    Length len_func;
1095      return dp_algorithm(len_func,0);
1096  }  }
1097    
1098  Data  Data
1099  Data::trace() const  Data::trace() const
1100  {  {
1101    profData->reduction2++;    profData->reduction2++;
1102    return dp_algorithm(DataAlgorithmAdapter<Trace>(0));    Trace trace_func;
1103      return dp_algorithm(trace_func,0);
1104  }  }
1105    
1106  Data  Data
# Line 1104  Data::transpose(int axis) const Line 1115  Data::transpose(int axis) const
1115  const boost::python::tuple  const boost::python::tuple
1116  Data::mindp() const  Data::mindp() const
1117  {  {
1118      // NB: calc_mindp had to be split off from mindp as boost::make_tuple causes an
1119      // abort (for unknown reasons) if there are openmp directives with it in the
1120      // surrounding function
1121    
1122      int SampleNo;
1123      int DataPointNo;
1124    
1125      calc_mindp(SampleNo,DataPointNo);
1126    
1127      return make_tuple(SampleNo,DataPointNo);
1128    }
1129    
1130    void
1131    Data::calc_mindp(int& SampleNo,
1132                     int& DataPointNo) const
1133    {
1134      int i,j;
1135      int lowi=0,lowj=0;
1136      double min=numeric_limits<double>::max();
1137    
1138    Data temp=minval();    Data temp=minval();
1139    
1140    int numSamples=temp.getNumSamples();    int numSamples=temp.getNumSamples();
1141    int numDPPSample=temp.getNumDataPointsPerSample();    int numDPPSample=temp.getNumDataPointsPerSample();
1142    
1143    int i,j,lowi=0,lowj=0;    double next,local_min;
1144    double min=numeric_limits<double>::max();    int local_lowi,local_lowj;
1145    
1146    for (i=0; i<numSamples; i++) {    #pragma omp parallel private(next,local_min,local_lowi,local_lowj)
1147      for (j=0; j<numDPPSample; j++) {    {
1148        double next=temp.getDataPoint(i,j)();      local_min=min;
1149        if (next<min) {      #pragma omp for private(i,j) schedule(static)
1150          min=next;      for (i=0; i<numSamples; i++) {
1151          lowi=i;        for (j=0; j<numDPPSample; j++) {
1152          lowj=j;          next=temp.getDataPoint(i,j)();
1153            if (next<local_min) {
1154              local_min=next;
1155              local_lowi=i;
1156              local_lowj=j;
1157            }
1158        }        }
1159      }      }
1160        #pragma omp critical
1161        if (local_min<min) {
1162          min=local_min;
1163          lowi=local_lowi;
1164          lowj=local_lowj;
1165        }
1166    }    }
1167    
1168    return make_tuple(lowi,lowj);    SampleNo = lowi;
1169      DataPointNo = lowj;
1170  }  }
1171    
1172  void  void

Legend:
Removed from v.126  
changed lines
  Added in v.148

  ViewVC Help
Powered by ViewVC 1.1.26