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

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

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

trunk/esys2/escript/src/Data/UnaryOp.h revision 97 by jgs, Tue Dec 14 05:39:33 2004 UTC trunk/escript/src/UnaryOp.h revision 1796 by jfenwick, Wed Sep 17 01:45:46 2008 UTC
# Line 1  Line 1 
1  // $Id$  
2  /*  /* $Id$ */
3   ******************************************************************************  
4   *                                                                            *  /*******************************************************
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *
6   *                                                                            *   *           Copyright 2003-2007 by ACceSS MNRF
7   * This software is the property of ACcESS. No part of this code              *   *       Copyright 2007 by University of Queensland
8   * may be copied in any form or by any means without the expressed written    *   *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *                http://esscc.uq.edu.au
10   * by any unauthorised person is illegal unless that person has a software    *   *        Primary Business: Queensland, Australia
11   * license agreement with ACcESS.                                             *   *  Licensed under the Open Software License version 3.0
12   *                                                                            *   *     http://www.opensource.org/licenses/osl-3.0.php
13   ******************************************************************************   *
14  */   *******************************************************/
15                                                                              
16  #if !defined escript_UnaryOp_20040315_H  #if !defined escript_UnaryOp_20040315_H
17  #define escript_UnaryOp_20040315_H  #define escript_UnaryOp_20040315_H
18    #include "system_dep.h"
19    
20  #include "escript/Data/DataException.h"  #include "DataConstant.h"
21  #include "escript/Data/DataArrayView.h"  #include "DataTagged.h"
22  #include "escript/Data/DataConstant.h"  #include "DataExpanded.h"
23  #include "escript/Data/DataExpanded.h"  #include "DataTypes.h"
 #include "escript/Data/DataTagged.h"  
   
 #include <iostream>  
 #include <boost/scoped_ptr.hpp>  
 #include <functional>  
 #include <string>  
24    
25  namespace escript {  namespace escript {
26    
# Line 36  namespace escript { Line 31  namespace escript {
31     Calls DataArrayView::unaryOp.     Calls DataArrayView::unaryOp.
32     For DataExpanded objects, operation is done in parallel.     For DataExpanded objects, operation is done in parallel.
33     \param data Input/Output - The data.     \param data Input/Output - The data.
34       \param operation Input - The operation to perform.
35  */  */
36    
37  template <class UnaryFunction>  template <class UnaryFunction>
# Line 45  unaryOp(DataExpanded& data, Line 41  unaryOp(DataExpanded& data,
41          UnaryFunction operation)          UnaryFunction operation)
42  {  {
43    int i,j;    int i,j;
44    DataArrayView::ValueType::size_type numDPPSample=data.getNumDPPSample();    DataTypes::ValueType::size_type numDPPSample=data.getNumDPPSample();
45    DataArrayView::ValueType::size_type numSamples=data.getNumSamples();    DataTypes::ValueType::size_type numSamples=data.getNumSamples();
46  #pragma omp parallel for private(i,j) schedule(static)    DataTypes::ValueType& left=data.getVector();
47      const DataTypes::ShapeType& shape=data.getShape();
48      #pragma omp parallel for private(i,j) schedule(static)
49    for (i=0;i<numSamples;i++) {    for (i=0;i<numSamples;i++) {
50      for (j=0;j<numDPPSample;j++) {      for (j=0;j<numDPPSample;j++) {
51        data.getPointDataView().unaryOp(data.getPointOffset(i,j),operation);        //data.getPointDataView().unaryOp(data.getPointOffset(i,j),operation);
52          DataMaths::unaryOp(left,shape,data.getPointOffset(i,j),operation);
53      }      }
54    }    }
55  }  }
# Line 65  unaryOp(DataTagged& data, Line 64  unaryOp(DataTagged& data,
64    const DataTagged::DataMapType& lookup=data.getTagLookup();    const DataTagged::DataMapType& lookup=data.getTagLookup();
65    DataTagged::DataMapType::const_iterator i;    DataTagged::DataMapType::const_iterator i;
66    DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();    DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();
67    DataArrayView& dataView=data.getPointDataView();    //DataArrayView& dataView=data.getPointDataView();
68      DataTypes::ValueType& left=data.getVector();
69      const DataTypes::ShapeType& shape=data.getShape();
70    for (i=lookup.begin();i!=lookupEnd;i++) {    for (i=lookup.begin();i!=lookupEnd;i++) {
71      dataView.unaryOp(i->second,operation);  //    dataView.unaryOp(i->second,operation);
72        DataMaths::unaryOp(left,shape,i->second,operation);
73    }    }
74    // perform the operation on the default value    // perform the operation on the default value
75    data.getDefaultValue().unaryOp(operation);    //data.getDefaultValue().unaryOp(operation);
76      DataMaths::unaryOp(left,shape,data.getDefaultOffset(),operation);
77  }  }
78    
79  template <class UnaryFunction>  template <class UnaryFunction>
# Line 79  void Line 82  void
82  unaryOp(DataConstant& data,  unaryOp(DataConstant& data,
83          UnaryFunction operation)          UnaryFunction operation)
84  {  {
85    data.getPointDataView().unaryOp(operation);    //data.getPointDataView().unaryOp(operation);
86      DataMaths::unaryOp(data.getVector(),data.getShape(),0,operation);
87  }  }
88    
89  } // end of namespace  } // end of namespace

Legend:
Removed from v.97  
changed lines
  Added in v.1796

  ViewVC Help
Powered by ViewVC 1.1.26