/[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 615 by elspeth, Wed Mar 22 02:12:00 2006 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
2  /*  /*
3   ******************************************************************************   ************************************************************
4   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *                                                          *
6   *                                                                            *   *              http://www.access.edu.au                    *
7   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
8   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
10   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
11   * license agreement with ACcESS.                                             *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
12  */  */
13                                                                                                                                                        
14  #if !defined escript_DataAlgorithm_20040714_H  #if !defined escript_DataAlgorithm_20040714_H
# Line 192  algorithm(DataTagged& data, Line 190  algorithm(DataTagged& data,
190            BinaryFunction operation,            BinaryFunction operation,
191        double initial_value)        double initial_value)
192  {  {
   const DataTagged::DataMapType& lookup=data.getTagLookup();  
   DataTagged::DataMapType::const_iterator i;  
   DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();  
   DataArrayView& dataView=data.getPointDataView();  
193    double current_value=initial_value;    double current_value=initial_value;
194    // perform the operation on each tagged value    // perform the operation on each tagged value
195    for (i=lookup.begin();i!=lookupEnd;i++) {    DataArrayView& dataView=data.getPointDataView();
196      const DataTagged::DataMapType& lookup=data.getTagLookup();
197      for (DataTagged::DataMapType::const_iterator i=lookup.begin(); i!=lookup.end(); i++) {
198      current_value=operation(current_value,dataView.reductionOp(i->second,operation,initial_value));      current_value=operation(current_value,dataView.reductionOp(i->second,operation,initial_value));
199    }    }
200    // perform the operation on the default value    // perform the operation on the default value
# Line 259  dp_algorithm(DataTagged& data, Line 255  dp_algorithm(DataTagged& data,
255               BinaryFunction operation,               BinaryFunction operation,
256           double initial_value)           double initial_value)
257  {  {
258    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  
259    // and assign this to the corresponding element in result    // and assign this to the corresponding element in result
260    for (i=lookup.begin();i!=lookupEnd;i++) {    const DataTagged::DataMapType& lookup=data.getTagLookup();
261      resultView.getData(i->second) =    for (DataTagged::DataMapType::const_iterator i=lookup.begin(); i!=lookup.end(); i++) {
262        dataView.reductionOp(i->second,operation,initial_value);      result.getDataPointByTag(i->first).getData(0) =
263          data.getDataPointByTag(i->first).reductionOp(operation,initial_value);
264    }    }
265    // perform the operation on the default data value    // perform the operation on the default data value
266    // and assign this to the default element in result    // and assign this to the default element in result
267    resultView.getData(0) =    result.getDefaultValue().getData(0) =
268      data.getDefaultValue().reductionOp(operation,initial_value);      data.getDefaultValue().reductionOp(operation,initial_value);
269  }  }
270    

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

  ViewVC Help
Powered by ViewVC 1.1.26