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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 615 - (hide 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 jgs 102 // $Id$
2 jgs 82 /*
3 elspeth 615 ************************************************************
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 jgs 82 */
13 jgs 474
14 jgs 102 #if !defined escript_UnaryOp_20040315_H
15 jgs 82 #define escript_UnaryOp_20040315_H
16    
17 jgs 474 #include "DataArrayView.h"
18     #include "DataConstant.h"
19 jgs 478 #include "DataTagged.h"
20 jgs 474 #include "DataExpanded.h"
21 jgs 82
22     namespace escript {
23    
24     /**
25     \brief
26 jgs 102 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 jgs 82 \param data Input/Output - The data.
31 jgs 121 \param operation Input - The operation to perform.
32 jgs 82 */
33 jgs 102
34 jgs 82 template <class UnaryFunction>
35 jgs 102 inline
36     void
37     unaryOp(DataExpanded& data,
38     UnaryFunction operation)
39 jgs 82 {
40     int i,j;
41     DataArrayView::ValueType::size_type numDPPSample=data.getNumDPPSample();
42     DataArrayView::ValueType::size_type numSamples=data.getNumSamples();
43 jgs 122 #pragma omp parallel for private(i,j) schedule(static)
44 jgs 102 for (i=0;i<numSamples;i++) {
45     for (j=0;j<numDPPSample;j++) {
46     data.getPointDataView().unaryOp(data.getPointOffset(i,j),operation);
47 jgs 82 }
48     }
49     }
50    
51     template <class UnaryFunction>
52 jgs 102 inline
53     void
54     unaryOp(DataTagged& data,
55     UnaryFunction operation)
56 jgs 82 {
57 jgs 102 // perform the operation on each tagged value
58 jgs 82 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 jgs 102 for (i=lookup.begin();i!=lookupEnd;i++) {
63 jgs 82 dataView.unaryOp(i->second,operation);
64     }
65 jgs 102 // perform the operation on the default value
66 jgs 82 data.getDefaultValue().unaryOp(operation);
67     }
68    
69     template <class UnaryFunction>
70 jgs 102 inline
71     void
72     unaryOp(DataConstant& data,
73     UnaryFunction operation)
74 jgs 82 {
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