/[escript]/branches/schroedinger/escript/src/DataLazy.h
ViewVC logotype

Contents of /branches/schroedinger/escript/src/DataLazy.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1888 - (show annotations)
Wed Oct 15 04:00:21 2008 UTC (11 years, 9 months ago) by jfenwick
File MIME type: text/plain
File size: 3047 byte(s)
Branch commit.
Added more binary ops.

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 by University of Queensland
5 * 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
14
15 #if !defined escript_DataLazy_20081008_H
16 #define escript_DataLazy_20081008_H
17 #include "system_dep.h"
18
19 #include "DataAbstract.h"
20 //#include "DataTypes.h"
21 //#include "FunctionSpace.h"
22
23 #include <string>
24 #include <functional>
25
26 #include "LocalOps.h" // for tensor_binary_op
27
28 namespace escript {
29
30 enum ES_optype
31 {
32 UNKNOWNOP=0,
33 IDENTITY=1,
34 ADD=2,
35 SUB=3,
36 MUL=4,
37 DIV=5,
38 SIN=6,
39 COS=7,
40 TAN=8,
41 ASIN=9,
42 ACOS=10,
43 ATAN=11,
44 SINH=12,
45 COSH=13,
46 TANH=14,
47 ERF=15,
48 ASINH=16,
49 ACOSH=17,
50 ATANH=18,
51 LOG10=19,
52 LOG=20,
53 SIGN=21,
54 ABS=22,
55 NEG=23,
56 POS=24,
57 EXP=25,
58 SQRT=26,
59 RECIP=27,
60 GZ=28,
61 LZ=29,
62 GEZ=30,
63 LEZ=31
64 };
65
66 const std::string&
67 opToString(ES_optype op);
68
69 /**
70 \class escript::DataLazy
71 \brief Wraps an expression tree of other DataObjects.
72 The values of DataPoints are computed when requested rather than all at once.
73
74 NOTE: This class assumes that the Data being pointed at are immutable.
75 */
76
77 class DataLazy;
78
79 typedef POINTER_WRAPPER_CLASS(DataLazy) DataLazy_ptr;
80 typedef POINTER_WRAPPER_CLASS(const DataLazy) const_DataLazy_ptr;
81
82 class DataLazy : public DataAbstract
83 {
84
85 typedef DataAbstract parent;
86 typedef DataTypes::ValueType ValueType;
87 typedef DataTypes::ShapeType ShapeType;
88
89 public:
90 ESCRIPT_DLL_API
91 DataLazy(DataAbstract_ptr p);
92
93 ESCRIPT_DLL_API
94 DataLazy(DataAbstract_ptr left, ES_optype op);
95
96
97
98 ESCRIPT_DLL_API
99 DataLazy(DataLazy_ptr left, DataLazy_ptr right, ES_optype op);
100
101 ESCRIPT_DLL_API
102 DataLazy(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op);
103
104 ESCRIPT_DLL_API
105 ~DataLazy();
106
107
108
109 /**
110 \brief Compute all data points in the expression tree
111 */
112 ESCRIPT_DLL_API
113 DataReady_ptr
114 resolve();
115
116 ESCRIPT_DLL_API
117 std::string
118 toString() const;
119
120 ESCRIPT_DLL_API
121 DataAbstract*
122 deepCopy();
123
124
125 /**
126 \brief
127 Return the number of doubles that would be stored for this Data object if it were resolved.
128 */
129 ESCRIPT_DLL_API
130 ValueType::size_type
131 getLength() const;
132
133
134 ESCRIPT_DLL_API
135 DataAbstract*
136 getSlice(const DataTypes::RegionType& region) const;
137
138
139 DataTypes::ValueType::size_type
140 getPointOffset(int sampleNo,
141 int dataPointNo) const;
142
143
144 ESCRIPT_DLL_API
145 int
146 getBuffsRequired() const;
147
148 private:
149 DataReady_ptr m_id;
150 DataLazy_ptr m_left, m_right;
151 ES_optype m_op;
152 size_t m_length; // number of values represented by the operation
153
154 int m_buffsRequired; // how many buffers are required to evaluate this expression
155 size_t m_samplesize; // number of values required to store a sample
156
157 const double*
158 resolveSample(ValueType& v,int sampleNo, size_t offset ) const;
159
160 void
161 intoString(std::ostringstream& oss) const;
162
163 };
164
165 }
166 #endif

  ViewVC Help
Powered by ViewVC 1.1.26