Escript
Revision_4320
Main Page
Namespaces
Classes
Files
File List
File Members
escript
src
DataLazy.h
Go to the documentation of this file.
1
2
/*****************************************************************************
3
*
4
* Copyright (c) 2003-2013 by University of Queensland
5
* http://www.uq.edu.au
6
*
7
* Primary Business: Queensland, Australia
8
* Licensed under the Open Software License version 3.0
9
* http://www.opensource.org/licenses/osl-3.0.php
10
*
11
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12
* Development since 2012 by School of Earth Sciences
13
*
14
*****************************************************************************/
15
16
17
#if !defined escript_DataLazy_20081008_H
18
#define escript_DataLazy_20081008_H
19
#include "
system_dep.h
"
20
21
#include "
DataAbstract.h
"
22
23
#include <string>
24
#include <functional>
25
26
#include "
LocalOps.h
"
// for tensor_binary_op
27
#include "
DataVector.h
"
// for ElementType
28
29
30
//#define LAZY_NODE_STORAGE
31
32
namespace
escript {
33
34
// For the purposes of unit testing and maintaining sanity, it is important that this enum be contiguous
35
enum
ES_optype
36
{
37
UNKNOWNOP
=0,
38
IDENTITY
=1,
39
ADD
=2,
40
SUB
=3,
41
MUL
=4,
42
DIV
=5,
43
POW
=6,
44
SIN
=
POW
+1,
45
COS
=
SIN
+1,
46
TAN
=
SIN
+2,
47
ASIN
=
SIN
+3,
48
ACOS
=
SIN
+4,
49
ATAN
=
SIN
+5,
50
SINH
=
SIN
+6,
51
COSH
=
SIN
+7,
52
TANH
=
SIN
+8,
53
ERF
=
SIN
+9,
54
ASINH
=
SIN
+10,
55
ACOSH
=
SIN
+11,
56
ATANH
=
SIN
+12,
57
LOG10
=
ATANH
+1,
58
LOG
=
LOG10
+1,
59
SIGN
=
LOG10
+2,
60
ABS
=
LOG10
+3,
61
NEG
=
LOG10
+4,
62
POS
=
LOG10
+5,
63
EXP
=
LOG10
+6,
64
SQRT
=
LOG10
+7,
65
RECIP
=
LOG10
+8,
66
GZ
=
RECIP
+1,
67
LZ
=
GZ
+1,
68
GEZ
=
GZ
+2,
69
LEZ
=
GZ
+3,
70
NEZ
=
GZ
+4,
71
EZ
=
GZ
+5,
72
SYM
=
EZ
+1,
73
NSYM
=
SYM
+1,
74
PROD
=
NSYM
+1,
75
TRANS
=
PROD
+1,
76
TRACE
=
TRANS
+1,
77
SWAP
=
TRACE
+1,
78
MINVAL
=
SWAP
+1,
79
MAXVAL
=
MINVAL
+1,
80
CONDEVAL
=
MAXVAL
+1
81
};
82
83
ESCRIPT_DLL_API
84
const
std::string&
85
opToString
(
ES_optype
op);
86
96
class
DataLazy
;
97
98
typedef
POINTER_WRAPPER_CLASS
(
DataLazy
)
DataLazy_ptr
;
99
typedef
POINTER_WRAPPER_CLASS
(const
DataLazy
)
const_DataLazy_ptr
;
100
101
class
DataLazy
: public
DataAbstract
102
{
103
104
typedef
DataAbstract
parent
;
105
typedef
DataTypes::ValueType
ValueType
;
106
typedef
DataTypes::ShapeType
ShapeType
;
107
108
public
:
114
ESCRIPT_DLL_API
115
DataLazy
(
DataAbstract_ptr
p);
116
117
125
ESCRIPT_DLL_API
126
DataLazy
(
DataAbstract_ptr
left,
ES_optype
op);
127
136
ESCRIPT_DLL_API
137
DataLazy
(
DataAbstract_ptr
left,
ES_optype
op,
double
tol);
138
147
ESCRIPT_DLL_API
148
DataLazy
(
DataAbstract_ptr
left,
ES_optype
op,
int
axis_offset);
149
150
158
ESCRIPT_DLL_API
159
DataLazy
(
DataAbstract_ptr
left,
DataAbstract_ptr
right,
ES_optype
op);
160
170
ESCRIPT_DLL_API
171
DataLazy
(
DataAbstract_ptr
left,
DataAbstract_ptr
right,
ES_optype
op,
int
axis_offset,
int
transpose
);
172
182
ESCRIPT_DLL_API
183
DataLazy
(
DataAbstract_ptr
left,
ES_optype
op,
const
int
axis0,
const
int
axis1);
184
191
ESCRIPT_DLL_API
192
DataLazy
(
DataAbstract_ptr
mask,
DataAbstract_ptr
left,
DataAbstract_ptr
right
/*, double tol*/
);
193
194
ESCRIPT_DLL_API
195
~
DataLazy
();
196
201
ESCRIPT_DLL_API
202
DataReady_ptr
203
resolve();
204
205
ESCRIPT_DLL_API
206
std::string
207
toString()
const
;
208
209
ESCRIPT_DLL_API
210
DataAbstract*
211
deepCopy();
212
213
218
ESCRIPT_DLL_API
219
ValueType::size_type
220
getLength
()
const
;
221
222
223
ESCRIPT_DLL_API
224
DataAbstract*
225
getSlice(
const
DataTypes::RegionType
& region)
const
;
226
227
228
DataTypes::ValueType::size_type
229
getPointOffset(
int
sampleNo,
230
int
dataPointNo)
const
;
231
232
DataTypes::ValueType::size_type
233
getPointOffset(
int
sampleNo,
234
int
dataPointNo);
235
239
ESCRIPT_DLL_API
240
size_t
241
getMaxSampleSize()
const
;
242
251
ESCRIPT_DLL_API
252
const
ValueType*
253
resolveSample(
int
sampleNo,
size_t
& roffset);
254
258
ESCRIPT_DLL_API
259
bool
260
actsExpanded()
const
;
261
266
ESCRIPT_DLL_API
267
virtual
void
268
setToZero();
269
270
271
ESCRIPT_DLL_API
272
void
273
resolveGroupWorker(std::vector<DataLazy*>& dats);
274
275
276
private
:
277
DataReady_ptr
m_id
;
// For IDENTITY nodes, stores a wrapped value.
278
DataLazy_ptr m_left,
m_right
, m_mask;
// operands for operation.
279
ES_optype
m_op
;
// operation to perform.
280
281
size_t
m_samplesize
;
// number of values required to store a sample
282
283
char
m_readytype
;
// E for expanded, T for tagged, C for constant
284
285
int
m_axis_offset
;
// required extra info for general tensor product
286
int
m_transpose
;
// offset and transpose are used for swapaxes as well
287
int
m_SL, m_SM,
m_SR
;
// computed properties used in general tensor product
288
289
290
double
m_tol
;
// required extra info for <>0 and ==0
291
292
size_t
m_children
;
293
size_t
m_height
;
294
295
int
*
m_sampleids
;
// may be NULL
296
DataVector
m_samples
;
297
301
void
LazyNodeSetup();
302
303
304
const
DataTypes::ValueType
*
305
resolveNodeUnary(
int
tid,
int
sampleNo,
size_t
& roffset);
306
307
308
const
DataTypes::ValueType
*
309
resolveNodeReduction(
int
tid,
int
sampleNo,
size_t
& roffset);
310
311
const
DataTypes::ValueType
*
312
resolveNodeSample(
int
tid,
int
sampleNo,
size_t
& roffset);
313
314
const
DataTypes::ValueType
*
315
resolveNodeBinary(
int
tid,
int
sampleNo,
size_t
& roffset);
316
317
const
DataTypes::ValueType
*
318
resolveNodeNP1OUT(
int
tid,
int
sampleNo,
size_t
& roffset);
319
320
const
DataTypes::ValueType
*
321
resolveNodeNP1OUT_P(
int
tid,
int
sampleNo,
size_t
& roffset);
322
323
const
DataTypes::ValueType
*
324
resolveNodeTProd(
int
tid,
int
sampleNo,
size_t
& roffset);
325
326
const
DataTypes::ValueType
*
327
resolveNodeNP1OUT_2P(
int
tid,
int
sampleNo,
size_t
& roffset);
328
329
const
DataTypes::ValueType
*
330
resolveNodeCondEval(
int
tid,
int
sampleNo,
size_t
& roffset);
331
335
void
336
intoString(std::ostringstream& oss)
const
;
337
341
void
342
intoTreeString(std::ostringstream& oss,std::string indent)
const
;
343
350
void
351
collapse();
// converts the node into an IDENTITY node
352
353
359
DataReady_ptr
360
collapseToReady();
361
366
void
367
resolveToIdentity();
368
372
void
373
makeIdentity(
const
DataReady_ptr
& p);
374
375
379
DataReady_ptr
380
resolveNodeWorker();
381
382
};
383
384
}
385
#endif
Generated on Fri Mar 15 2013 14:07:49 for Escript by
1.8.1.2