/[escript]/branches/RW_WIN32/escript/src/Data/UnaryOp.h
ViewVC logotype

Contents of /branches/RW_WIN32/escript/src/Data/UnaryOp.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 186 - (show annotations)
Sun Nov 20 10:51:16 2005 UTC (13 years, 11 months ago) by robwdcock
File MIME type: text/plain
File size: 3057 byte(s)
PARTIAL WIN32 PORT
+ Paso, ext_math and mmio libraries build using scons in top level directory
+ Scons build system currently hard coded against RW's third-party library paths.
+ Still lots TODO to complete port and build system 
1 // $Id$
2 /*
3 ******************************************************************************
4 * *
5 * COPYRIGHT ACcESS 2004 - All Rights Reserved *
6 * *
7 * This software is the property of ACcESS. No part of this code *
8 * may be copied in any form or by any means without the expressed written *
9 * consent of ACcESS. Copying, use or modification of this software *
10 * by any unauthorised person is illegal unless that person has a software *
11 * license agreement with ACcESS. *
12 * *
13 ******************************************************************************
14 */
15
16 #if !defined escript_UnaryOp_20040315_H
17 #define escript_UnaryOp_20040315_H
18 #ifdef MSVC
19 #ifdef ESCRIPT_EXPORTS
20 #define ESCRIPT_DLL __declspec(dllexport)
21 #else
22 #define ESCRIPT_DLL __declspec(dllimport)
23 #endif
24 #else
25 #define ESCRIPT_DLL
26 #endif
27
28 #include "escript/Data/DataException.h"
29 #include "escript/Data/DataArrayView.h"
30 #include "escript/Data/DataConstant.h"
31 #include "escript/Data/DataExpanded.h"
32 #include "escript/Data/DataTagged.h"
33
34 #include <iostream>
35 #include <boost/scoped_ptr.hpp>
36 #include <functional>
37 #include <string>
38
39 namespace escript {
40
41 /**
42 \brief
43 Perform the given unary operation on each data point of the given Data object.
44 Called by Data::unaryOp.
45 Calls DataArrayView::unaryOp.
46 For DataExpanded objects, operation is done in parallel.
47 \param data Input/Output - The data.
48 \param operation Input - The operation to perform.
49 */
50
51 template <class UnaryFunction>
52 inline
53 void
54 unaryOp(DataExpanded& data,
55 UnaryFunction operation)
56 {
57 int i,j;
58 DataArrayView::ValueType::size_type numDPPSample=data.getNumDPPSample();
59 DataArrayView::ValueType::size_type numSamples=data.getNumSamples();
60 #pragma omp parallel for private(i,j) schedule(static)
61 for (i=0;i<numSamples;i++) {
62 for (j=0;j<numDPPSample;j++) {
63 data.getPointDataView().unaryOp(data.getPointOffset(i,j),operation);
64 }
65 }
66 }
67
68 template <class UnaryFunction>
69 inline
70 void
71 unaryOp(DataTagged& data,
72 UnaryFunction operation)
73 {
74 // perform the operation on each tagged value
75 const DataTagged::DataMapType& lookup=data.getTagLookup();
76 DataTagged::DataMapType::const_iterator i;
77 DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();
78 DataArrayView& dataView=data.getPointDataView();
79 for (i=lookup.begin();i!=lookupEnd;i++) {
80 dataView.unaryOp(i->second,operation);
81 }
82 // perform the operation on the default value
83 data.getDefaultValue().unaryOp(operation);
84 }
85
86 template <class UnaryFunction>
87 inline
88 void
89 unaryOp(DataConstant& data,
90 UnaryFunction operation)
91 {
92 data.getPointDataView().unaryOp(operation);
93 }
94
95 } // end of namespace
96 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26