/[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 1697 - (show annotations)
Mon Aug 11 06:29:54 2008 UTC (11 years, 3 months ago) by jfenwick
File MIME type: text/plain
File size: 2215 byte(s)
Moved ValueType, ShapeType, RegionType, RegionLoopRangeType and maxRank
From DataArrayView.h to DataTypes.h

This is a simple rename but did require modifying a lot of files.


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 #include "DataTypes.h"
25
26 namespace escript {
27
28 /**
29 \brief
30 Perform the given unary operation on each data point of the given Data object.
31 Called by Data::unaryOp.
32 Calls DataArrayView::unaryOp.
33 For DataExpanded objects, operation is done in parallel.
34 \param data Input/Output - The data.
35 \param operation Input - The operation to perform.
36 */
37
38 template <class UnaryFunction>
39 inline
40 void
41 unaryOp(DataExpanded& data,
42 UnaryFunction operation)
43 {
44 int i,j;
45 DataTypes::ValueType::size_type numDPPSample=data.getNumDPPSample();
46 DataTypes::ValueType::size_type numSamples=data.getNumSamples();
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 }
52 }
53 }
54
55 template <class UnaryFunction>
56 inline
57 void
58 unaryOp(DataTagged& data,
59 UnaryFunction operation)
60 {
61 // perform the operation on each tagged value
62 const DataTagged::DataMapType& lookup=data.getTagLookup();
63 DataTagged::DataMapType::const_iterator i;
64 DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();
65 DataArrayView& dataView=data.getPointDataView();
66 for (i=lookup.begin();i!=lookupEnd;i++) {
67 dataView.unaryOp(i->second,operation);
68 }
69 // perform the operation on the default value
70 data.getDefaultValue().unaryOp(operation);
71 }
72
73 template <class UnaryFunction>
74 inline
75 void
76 unaryOp(DataConstant& data,
77 UnaryFunction operation)
78 {
79 data.getPointDataView().unaryOp(operation);
80 }
81
82 } // end of namespace
83 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26