/[escript]/branches/arrayview_from_1695_trunk/escript/src/UnaryOp.h
ViewVC logotype

Annotation of /branches/arrayview_from_1695_trunk/escript/src/UnaryOp.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1697 - (hide annotations)
Mon Aug 11 06:29:54 2008 UTC (11 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 2215 byte(s)
Moved ValueType, ShapeType, RegionType, RegionLoopRangeType and maxRank
From DataArrayView.h to DataTypes.h

This is a simple rename but did require modifying a lot of files.


1 jgs 474
2 ksteube 1312 /* $Id$ */
3    
4     /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16 jgs 102 #if !defined escript_UnaryOp_20040315_H
17 jgs 82 #define escript_UnaryOp_20040315_H
18 woo409 757 #include "system_dep.h"
19 jgs 82
20 jgs 474 #include "DataArrayView.h"
21     #include "DataConstant.h"
22 jgs 478 #include "DataTagged.h"
23 jgs 474 #include "DataExpanded.h"
24 jfenwick 1697 #include "DataTypes.h"
25 jgs 82
26     namespace escript {
27    
28     /**
29     \brief
30 jgs 102 Perform the given unary operation on each data point of the given Data object.
31     Called by Data::unaryOp.
32     Calls DataArrayView::unaryOp.
33     For DataExpanded objects, operation is done in parallel.
34 jgs 82 \param data Input/Output - The data.
35 jgs 121 \param operation Input - The operation to perform.
36 jgs 82 */
37 jgs 102
38 jgs 82 template <class UnaryFunction>
39 jgs 102 inline
40     void
41     unaryOp(DataExpanded& data,
42     UnaryFunction operation)
43 jgs 82 {
44     int i,j;
45 jfenwick 1697 DataTypes::ValueType::size_type numDPPSample=data.getNumDPPSample();
46     DataTypes::ValueType::size_type numSamples=data.getNumSamples();
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     data.getPointDataView().unaryOp(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     DataArrayView& dataView=data.getPointDataView();
66 jgs 102 for (i=lookup.begin();i!=lookupEnd;i++) {
67 jgs 82 dataView.unaryOp(i->second,operation);
68     }
69 jgs 102 // perform the operation on the default value
70 jgs 82 data.getDefaultValue().unaryOp(operation);
71     }
72    
73     template <class UnaryFunction>
74 jgs 102 inline
75     void
76     unaryOp(DataConstant& data,
77     UnaryFunction operation)
78 jgs 82 {
79     data.getPointDataView().unaryOp(operation);
80     }
81    
82     } // end of namespace
83     #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26