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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 615 - (show annotations)
Wed Mar 22 02:12:00 2006 UTC (13 years, 7 months ago) by elspeth
Original Path: trunk/escript/src/UnaryOp.h
File MIME type: text/plain
File size: 2310 byte(s)
More copyright information.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26