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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 757 - (hide annotations)
Mon Jun 26 13:12:56 2006 UTC (13 years, 3 months ago) by woo409
File MIME type: text/plain
File size: 2334 byte(s)
+ Merge of intelc_win32 branch (revision 741:755) with trunk. Tested on iVEC altix (run_tests and py_tests all pass)

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26