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

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

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

revision 478 by jgs, Tue Jan 31 02:21:49 2006 UTC revision 559 by jgs, Thu Feb 23 01:43:44 2006 UTC
# Line 192  algorithm(DataTagged& data, Line 192  algorithm(DataTagged& data,
192            BinaryFunction operation,            BinaryFunction operation,
193        double initial_value)        double initial_value)
194  {  {
   const DataTagged::DataMapType& lookup=data.getTagLookup();  
   DataTagged::DataMapType::const_iterator i;  
   DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();  
   DataArrayView& dataView=data.getPointDataView();  
195    double current_value=initial_value;    double current_value=initial_value;
196    // perform the operation on each tagged value    // perform the operation on each tagged value
197    for (i=lookup.begin();i!=lookupEnd;i++) {    DataArrayView& dataView=data.getPointDataView();
198      const DataTagged::DataMapType& lookup=data.getTagLookup();
199      for (DataTagged::DataMapType::const_iterator i=lookup.begin(); i!=lookup.end(); i++) {
200      current_value=operation(current_value,dataView.reductionOp(i->second,operation,initial_value));      current_value=operation(current_value,dataView.reductionOp(i->second,operation,initial_value));
201    }    }
202    // perform the operation on the default value    // perform the operation on the default value
# Line 259  dp_algorithm(DataTagged& data, Line 257  dp_algorithm(DataTagged& data,
257               BinaryFunction operation,               BinaryFunction operation,
258           double initial_value)           double initial_value)
259  {  {
260    const DataTagged::DataMapType& lookup=data.getTagLookup();    // perform the operation on each tagged value in data
   DataTagged::DataMapType::const_iterator i;  
   DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();  
   DataArrayView dataView=data.getPointDataView();  
   DataArrayView resultView=result.getPointDataView();  
   // perform the operation on each tagged data value  
261    // and assign this to the corresponding element in result    // and assign this to the corresponding element in result
262    for (i=lookup.begin();i!=lookupEnd;i++) {    const DataTagged::DataMapType& lookup=data.getTagLookup();
263      resultView.getData(i->second) =    for (DataTagged::DataMapType::const_iterator i=lookup.begin(); i!=lookup.end(); i++) {
264        dataView.reductionOp(i->second,operation,initial_value);      result.getDataPointByTag(i->first).getData(0) =
265          data.getDataPointByTag(i->first).reductionOp(operation,initial_value);
266    }    }
267    // perform the operation on the default data value    // perform the operation on the default data value
268    // and assign this to the default element in result    // and assign this to the default element in result
269    resultView.getData(0) =    result.getDefaultValue().getData(0) =
270      data.getDefaultValue().reductionOp(operation,initial_value);      data.getDefaultValue().reductionOp(operation,initial_value);
271  }  }
272    

Legend:
Removed from v.478  
changed lines
  Added in v.559

  ViewVC Help
Powered by ViewVC 1.1.26