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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 478 - (hide annotations)
Tue Jan 31 02:21:49 2006 UTC (13 years, 8 months ago) by jgs
File MIME type: text/plain
File size: 2632 byte(s)
rationalise #includes

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26