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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1388 - (show annotations)
Fri Jan 11 07:45:58 2008 UTC (11 years, 9 months ago) by trankine
File MIME type: text/plain
File size: 2200 byte(s)
And get the *(&(*&(* name right
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 "DataArrayView.h"
21 #include "DataConstant.h"
22 #include "DataTagged.h"
23 #include "DataExpanded.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 DataArrayView::ValueType::size_type numDPPSample=data.getNumDPPSample();
45 DataArrayView::ValueType::size_type numSamples=data.getNumSamples();
46 #pragma omp parallel for private(i,j) schedule(static)
47 for (i=0;i<numSamples;i++) {
48 for (j=0;j<numDPPSample;j++) {
49 data.getPointDataView().unaryOp(data.getPointOffset(i,j),operation);
50 }
51 }
52 }
53
54 template <class UnaryFunction>
55 inline
56 void
57 unaryOp(DataTagged& data,
58 UnaryFunction operation)
59 {
60 // perform the operation on each tagged value
61 const DataTagged::DataMapType& lookup=data.getTagLookup();
62 DataTagged::DataMapType::const_iterator i;
63 DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();
64 DataArrayView& dataView=data.getPointDataView();
65 for (i=lookup.begin();i!=lookupEnd;i++) {
66 dataView.unaryOp(i->second,operation);
67 }
68 // perform the operation on the default value
69 data.getDefaultValue().unaryOp(operation);
70 }
71
72 template <class UnaryFunction>
73 inline
74 void
75 unaryOp(DataConstant& data,
76 UnaryFunction operation)
77 {
78 data.getPointDataView().unaryOp(operation);
79 }
80
81 } // end of namespace
82 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26