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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 155 - (hide annotations)
Wed Nov 9 02:02:19 2005 UTC (14 years ago) by jgs
Original Path: trunk/escript/src/Data/UnaryOp.h
File MIME type: text/plain
File size: 2892 byte(s)
move all directories from trunk/esys2 into trunk and remove esys2

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26