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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 757 - (show annotations)
Mon Jun 26 13:12:56 2006 UTC (13 years, 5 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 // $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 #include "system_dep.h"
17
18 #include "DataArrayView.h"
19 #include "DataConstant.h"
20 #include "DataTagged.h"
21 #include "DataExpanded.h"
22
23 namespace escript {
24
25 /**
26 \brief
27 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 \param data Input/Output - The data.
32 \param operation Input - The operation to perform.
33 */
34
35 template <class UnaryFunction>
36 inline
37 void
38 unaryOp(DataExpanded& data,
39 UnaryFunction operation)
40 {
41 int i,j;
42 DataArrayView::ValueType::size_type numDPPSample=data.getNumDPPSample();
43 DataArrayView::ValueType::size_type numSamples=data.getNumSamples();
44 #pragma omp parallel for private(i,j) schedule(static)
45 for (i=0;i<numSamples;i++) {
46 for (j=0;j<numDPPSample;j++) {
47 data.getPointDataView().unaryOp(data.getPointOffset(i,j),operation);
48 }
49 }
50 }
51
52 template <class UnaryFunction>
53 inline
54 void
55 unaryOp(DataTagged& data,
56 UnaryFunction operation)
57 {
58 // perform the operation on each tagged value
59 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 for (i=lookup.begin();i!=lookupEnd;i++) {
64 dataView.unaryOp(i->second,operation);
65 }
66 // perform the operation on the default value
67 data.getDefaultValue().unaryOp(operation);
68 }
69
70 template <class UnaryFunction>
71 inline
72 void
73 unaryOp(DataConstant& data,
74 UnaryFunction operation)
75 {
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