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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1796 - (show annotations)
Wed Sep 17 01:45:46 2008 UTC (11 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 2663 byte(s)
Merged noarrayview branch onto trunk.


1
2 /* $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 #if !defined escript_UnaryOp_20040315_H
17 #define escript_UnaryOp_20040315_H
18 #include "system_dep.h"
19
20 #include "DataConstant.h"
21 #include "DataTagged.h"
22 #include "DataExpanded.h"
23 #include "DataTypes.h"
24
25 namespace escript {
26
27 /**
28 \brief
29 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 \param data Input/Output - The data.
34 \param operation Input - The operation to perform.
35 */
36
37 template <class UnaryFunction>
38 inline
39 void
40 unaryOp(DataExpanded& data,
41 UnaryFunction operation)
42 {
43 int i,j;
44 DataTypes::ValueType::size_type numDPPSample=data.getNumDPPSample();
45 DataTypes::ValueType::size_type numSamples=data.getNumSamples();
46 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++) {
50 for (j=0;j<numDPPSample;j++) {
51 //data.getPointDataView().unaryOp(data.getPointOffset(i,j),operation);
52 DataMaths::unaryOp(left,shape,data.getPointOffset(i,j),operation);
53 }
54 }
55 }
56
57 template <class UnaryFunction>
58 inline
59 void
60 unaryOp(DataTagged& data,
61 UnaryFunction operation)
62 {
63 // perform the operation on each tagged value
64 const DataTagged::DataMapType& lookup=data.getTagLookup();
65 DataTagged::DataMapType::const_iterator i;
66 DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();
67 //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++) {
71 // dataView.unaryOp(i->second,operation);
72 DataMaths::unaryOp(left,shape,i->second,operation);
73 }
74 // perform the operation on the default value
75 //data.getDefaultValue().unaryOp(operation);
76 DataMaths::unaryOp(left,shape,data.getDefaultOffset(),operation);
77 }
78
79 template <class UnaryFunction>
80 inline
81 void
82 unaryOp(DataConstant& data,
83 UnaryFunction operation)
84 {
85 //data.getPointDataView().unaryOp(operation);
86 DataMaths::unaryOp(data.getVector(),data.getShape(),0,operation);
87 }
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