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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1889 - (hide annotations)
Thu Oct 16 05:57:09 2008 UTC (11 years, 7 months ago) by jfenwick
File MIME type: text/plain
File size: 3418 byte(s)
Branch commit
Rewrote resolve to take into account Tagged and Constant Data.
Mixing expanded and Tagged does not work yet.

1 jfenwick 1865
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 jfenwick 1868 #include <functional>
25 jfenwick 1865
26 jfenwick 1879 #include "LocalOps.h" // for tensor_binary_op
27    
28 jfenwick 1865 namespace escript {
29    
30     enum ES_optype
31     {
32     UNKNOWNOP=0,
33 jfenwick 1868 IDENTITY=1,
34     ADD=2,
35     SUB=3,
36     MUL=4,
37 jfenwick 1886 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 jfenwick 1888 POS=24,
57     EXP=25,
58     SQRT=26,
59     RECIP=27,
60     GZ=28,
61     LZ=29,
62     GEZ=30,
63     LEZ=31
64 jfenwick 1865 };
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 jfenwick 1879
74     NOTE: This class assumes that the Data being pointed at are immutable.
75 jfenwick 1865 */
76    
77 jfenwick 1879 class DataLazy;
78    
79     typedef POINTER_WRAPPER_CLASS(DataLazy) DataLazy_ptr;
80     typedef POINTER_WRAPPER_CLASS(const DataLazy) const_DataLazy_ptr;
81    
82 jfenwick 1865 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 jfenwick 1886 DataLazy(DataAbstract_ptr left, ES_optype op);
95    
96    
97 jfenwick 1889 /*
98 jfenwick 1886 ESCRIPT_DLL_API
99 jfenwick 1889 DataLazy(DataLazy_ptr left, DataLazy_ptr right, ES_optype op);*/
100 jfenwick 1879
101     ESCRIPT_DLL_API
102 jfenwick 1865 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 jfenwick 1879 DataReady_ptr
114     resolve();
115 jfenwick 1865
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 jfenwick 1879
144     ESCRIPT_DLL_API
145     int
146     getBuffsRequired() const;
147    
148 jfenwick 1889
149    
150 jfenwick 1865 private:
151 jfenwick 1879 DataReady_ptr m_id;
152     DataLazy_ptr m_left, m_right;
153 jfenwick 1865 ES_optype m_op;
154 jfenwick 1879 size_t m_length; // number of values represented by the operation
155    
156     int m_buffsRequired; // how many buffers are required to evaluate this expression
157     size_t m_samplesize; // number of values required to store a sample
158    
159 jfenwick 1884 const double*
160 jfenwick 1889 resolveSample(ValueType& v,int sampleNo, size_t offset );
161 jfenwick 1879
162 jfenwick 1889 const double*
163     resolveSample2(ValueType& v,int sampleNo, size_t offset );
164    
165    
166 jfenwick 1886 void
167     intoString(std::ostringstream& oss) const;
168    
169 jfenwick 1889 char m_readytype;
170    
171     void
172     collapse(); // converts the node into an IDENTITY node
173    
174     DataReady_ptr
175     collapseToReady();
176    
177     const double*
178     resolveUnary(ValueType& v,int sampleNo, size_t offset) const;
179    
180     const double*
181     resolveBinary(ValueType& v,int sampleNo, size_t offset) const;
182    
183    
184 jfenwick 1865 };
185    
186     }
187     #endif

  ViewVC Help
Powered by ViewVC 1.1.26