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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (hide annotations)
Tue Oct 26 06:53:54 2004 UTC (15 years ago) by jgs
File MIME type: text/plain
File size: 2688 byte(s)
Initial revision

1 jgs 82 /*
2     ******************************************************************************
3     * *
4     * COPYRIGHT ACcESS 2004 - All Rights Reserved *
5     * *
6     * This software is the property of ACcESS. No part of this code *
7     * may be copied in any form or by any means without the expressed written *
8     * consent of ACcESS. Copying, use or modification of this software *
9     * by any unauthorised person is illegal unless that person has a software *
10     * license agreement with ACcESS. *
11     * *
12     ******************************************************************************
13     */
14    
15     #if !defined escript_UnaryOp_20040315_H
16     #define escript_UnaryOp_20040315_H
17    
18     #include "escript/Data/DataException.h"
19     #include "escript/Data/DataArrayView.h"
20     #include "escript/Data/DataConstant.h"
21     #include "escript/Data/DataExpanded.h"
22     #include "escript/Data/DataTagged.h"
23    
24     #include <iostream>
25     #include <boost/scoped_ptr.hpp>
26     #include <functional>
27     #include <string>
28    
29     namespace escript {
30    
31     /**
32     \brief
33     Perform the given unary operation.
34     \param data Input/Output - The data.
35     */
36     template <class UnaryFunction>
37     inline void unaryOp(DataExpanded& data, UnaryFunction operation)
38     {
39     int i,j;
40     DataArrayView::ValueType::size_type numDPPSample=data.getNumDPPSample();
41     DataArrayView::ValueType::size_type numSamples=data.getNumSamples();
42     #pragma omp parallel for private(i,j) schedule(static)
43     for (i=0;i<numSamples;++i) {
44     for (j=0;j<numDPPSample;++j) {
45     data.getPointDataView().unaryOp(data.getPointOffset(i,j),
46     operation);
47     }
48     }
49     }
50    
51     template <class UnaryFunction>
52     inline void unaryOp(DataTagged& data, UnaryFunction operation)
53     {
54     //
55     // perform the operation on each tagged value including the default
56     const DataTagged::DataMapType& lookup=data.getTagLookup();
57     DataTagged::DataMapType::const_iterator i;
58     DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();
59     DataArrayView& dataView=data.getPointDataView();
60     for (i=lookup.begin();i!=lookupEnd;++i) {
61     dataView.unaryOp(i->second,operation);
62     }
63     //
64     // finally perform the operation on the default value
65     data.getDefaultValue().unaryOp(operation);
66     }
67    
68     template <class UnaryFunction>
69     inline void unaryOp(DataConstant& data, UnaryFunction operation)
70     {
71     data.getPointDataView().unaryOp(operation);
72     }
73    
74     } // end of namespace
75     #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26