/[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 1312 - (hide annotations)
Mon Sep 24 06:18:44 2007 UTC (12 years, 1 month ago) by ksteube
Original Path: trunk/escript/src/UnaryOp.h
File MIME type: text/plain
File size: 2200 byte(s)
The MPI branch is hereby closed. All future work should be in trunk.

Previously in revision 1295 I merged the latest changes to trunk into trunk-mpi-branch.
In this revision I copied all files from trunk-mpi-branch over the corresponding
trunk files. I did not use 'svn merge', it was a copy.

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