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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2881 - (hide annotations)
Thu Jan 28 02:03:15 2010 UTC (10 years ago) by jfenwick
File MIME type: text/plain
File size: 2364 byte(s)
Don't panic.
Updating copyright stamps

1 jgs 474
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1811 * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 ksteube 1312
14 ksteube 1811
15 jgs 102 #if !defined escript_UnaryOp_20040315_H
16 jgs 82 #define escript_UnaryOp_20040315_H
17 woo409 757 #include "system_dep.h"
18 jgs 82
19 jgs 474 #include "DataConstant.h"
20 jgs 478 #include "DataTagged.h"
21 jgs 474 #include "DataExpanded.h"
22 jfenwick 1796 #include "DataTypes.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 jfenwick 1796 DataTypes::ValueType::size_type numDPPSample=data.getNumDPPSample();
44     DataTypes::ValueType::size_type numSamples=data.getNumSamples();
45 jfenwick 2271 DataTypes::ValueType& left=data.getVectorRW();
46 jfenwick 1796 const DataTypes::ShapeType& shape=data.getShape();
47 jgs 122 #pragma omp parallel for private(i,j) schedule(static)
48 jgs 102 for (i=0;i<numSamples;i++) {
49     for (j=0;j<numDPPSample;j++) {
50 jfenwick 1796 DataMaths::unaryOp(left,shape,data.getPointOffset(i,j),operation);
51 jgs 82 }
52     }
53     }
54    
55     template <class UnaryFunction>
56 jgs 102 inline
57     void
58     unaryOp(DataTagged& data,
59     UnaryFunction operation)
60 jgs 82 {
61 jgs 102 // perform the operation on each tagged value
62 jgs 82 const DataTagged::DataMapType& lookup=data.getTagLookup();
63     DataTagged::DataMapType::const_iterator i;
64     DataTagged::DataMapType::const_iterator lookupEnd=lookup.end();
65 jfenwick 2271 DataTypes::ValueType& left=data.getVectorRW();
66 jfenwick 1796 const DataTypes::ShapeType& shape=data.getShape();
67 jgs 102 for (i=lookup.begin();i!=lookupEnd;i++) {
68 jfenwick 1796 DataMaths::unaryOp(left,shape,i->second,operation);
69 jgs 82 }
70 jgs 102 // perform the operation on the default value
71 jfenwick 1796 DataMaths::unaryOp(left,shape,data.getDefaultOffset(),operation);
72 jgs 82 }
73    
74     template <class UnaryFunction>
75 jgs 102 inline
76     void
77     unaryOp(DataConstant& data,
78     UnaryFunction operation)
79 jgs 82 {
80 jfenwick 2271 DataMaths::unaryOp(data.getVectorRW(),data.getShape(),0,operation);
81 jgs 82 }
82    
83     } // end of namespace
84     #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26