/[escript]/branches/arrayview_from_1695_trunk/escript/src/UnaryOp.h
ViewVC logotype

Annotation of /branches/arrayview_from_1695_trunk/escript/src/UnaryOp.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1726 - (hide annotations)
Tue Aug 26 03:33:34 2008 UTC (11 years, 1 month ago) by jfenwick
File MIME type: text/plain
File size: 2663 byte(s)
BinaryOp and UnaryOp - modified to accept the extra parameters required 
to operate without DataArrayView.  There are still a few parallel 
methods which accept them as params.

Added getVector() members to DataAbstract - these versions will throw.
DataC.cpp - uses new method to get the shape.
Added constant form of getVector() to DataConstant
Fixed the #include protection on DataMaths.h


1 jgs 474
2 ksteube 1312 /* $Id$ */
3    
4     /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16 jgs 102 #if !defined escript_UnaryOp_20040315_H
17 jgs 82 #define escript_UnaryOp_20040315_H
18 woo409 757 #include "system_dep.h"
19 jgs 82
20 jgs 474 #include "DataConstant.h"
21 jgs 478 #include "DataTagged.h"
22 jgs 474 #include "DataExpanded.h"
23 jfenwick 1697 #include "DataTypes.h"
24 jgs 82
25     namespace escript {
26    
27     /**
28     \brief
29 jgs 102 Perform the given unary operation on each data point of the given Data object.
30     Called by Data::unaryOp.
31     Calls DataArrayView::unaryOp.
32     For DataExpanded objects, operation is done in parallel.
33 jgs 82 \param data Input/Output - The data.
34 jgs 121 \param operation Input - The operation to perform.
35 jgs 82 */
36 jgs 102
37 jgs 82 template <class UnaryFunction>
38 jgs 102 inline
39     void
40     unaryOp(DataExpanded& data,
41     UnaryFunction operation)
42 jgs 82 {
43     int i,j;
44 jfenwick 1697 DataTypes::ValueType::size_type numDPPSample=data.getNumDPPSample();
45     DataTypes::ValueType::size_type numSamples=data.getNumSamples();
46 jfenwick 1726 DataTypes::ValueType& left=data.getVector();
47     const DataTypes::ShapeType& shape=data.getShape();
48 jgs 122 #pragma omp parallel for private(i,j) schedule(static)
49 jgs 102 for (i=0;i<numSamples;i++) {
50     for (j=0;j<numDPPSample;j++) {
51 jfenwick 1726 //data.getPointDataView().unaryOp(data.getPointOffset(i,j),operation);
52     DataMaths::unaryOp(left,shape,data.getPointOffset(i,j),operation);
53 jgs 82 }
54     }
55     }
56    
57     template <class UnaryFunction>
58 jgs 102 inline
59     void
60     unaryOp(DataTagged& data,
61     UnaryFunction operation)
62 jgs 82 {
63 jgs 102 // perform the operation on each tagged value
64 jgs 82 const DataTagged::DataMapType& lookup=data.getTagLookup();
65     DataTagged::DataMapType::const_iterator i;
66     DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();
67 jfenwick 1726 //DataArrayView& dataView=data.getPointDataView();
68     DataTypes::ValueType& left=data.getVector();
69     const DataTypes::ShapeType& shape=data.getShape();
70 jgs 102 for (i=lookup.begin();i!=lookupEnd;i++) {
71 jfenwick 1726 // dataView.unaryOp(i->second,operation);
72     DataMaths::unaryOp(left,shape,i->second,operation);
73 jgs 82 }
74 jgs 102 // perform the operation on the default value
75 jfenwick 1726 //data.getDefaultValue().unaryOp(operation);
76     DataMaths::unaryOp(left,shape,data.getDefaultOffset(),operation);
77 jgs 82 }
78    
79     template <class UnaryFunction>
80 jgs 102 inline
81     void
82     unaryOp(DataConstant& data,
83     UnaryFunction operation)
84 jgs 82 {
85 jfenwick 1726 //data.getPointDataView().unaryOp(operation);
86     DataMaths::unaryOp(data.getVector(),data.getShape(),0,operation);
87 jgs 82 }
88    
89     } // end of namespace
90     #endif

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26