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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (11 years, 2 months ago) by ksteube
File MIME type: text/plain
File size: 2628 byte(s)
Copyright updated in all files

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26