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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1886 - (hide annotations)
Wed Oct 15 01:34:18 2008 UTC (11 years, 5 months ago) by jfenwick
Original Path: branches/schroedinger/escript/src/DataLazy.h
File MIME type: text/plain
File size: 2983 byte(s)
Branch commit.
Added unary ops up to pos.
toString now prints expression.
Added inlines to UnaryFuncs.h.

Still only supporting DataExpanded.

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     POS=24
57 jfenwick 1865 };
58    
59     const std::string&
60     opToString(ES_optype op);
61    
62     /**
63     \class escript::DataLazy
64     \brief Wraps an expression tree of other DataObjects.
65     The values of DataPoints are computed when requested rather than all at once.
66 jfenwick 1879
67     NOTE: This class assumes that the Data being pointed at are immutable.
68 jfenwick 1865 */
69    
70 jfenwick 1879 class DataLazy;
71    
72     typedef POINTER_WRAPPER_CLASS(DataLazy) DataLazy_ptr;
73     typedef POINTER_WRAPPER_CLASS(const DataLazy) const_DataLazy_ptr;
74    
75 jfenwick 1865 class DataLazy : public DataAbstract
76     {
77    
78     typedef DataAbstract parent;
79     typedef DataTypes::ValueType ValueType;
80     typedef DataTypes::ShapeType ShapeType;
81    
82     public:
83     ESCRIPT_DLL_API
84     DataLazy(DataAbstract_ptr p);
85    
86     ESCRIPT_DLL_API
87 jfenwick 1886 DataLazy(DataAbstract_ptr left, ES_optype op);
88    
89    
90    
91     ESCRIPT_DLL_API
92 jfenwick 1879 DataLazy(DataLazy_ptr left, DataLazy_ptr right, ES_optype op);
93    
94     ESCRIPT_DLL_API
95 jfenwick 1865 DataLazy(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op);
96    
97     ESCRIPT_DLL_API
98     ~DataLazy();
99    
100    
101    
102     /**
103     \brief Compute all data points in the expression tree
104     */
105     ESCRIPT_DLL_API
106 jfenwick 1879 DataReady_ptr
107     resolve();
108 jfenwick 1865
109     ESCRIPT_DLL_API
110     std::string
111     toString() const;
112    
113     ESCRIPT_DLL_API
114     DataAbstract*
115     deepCopy();
116    
117    
118     /**
119     \brief
120     Return the number of doubles that would be stored for this Data object if it were resolved.
121     */
122     ESCRIPT_DLL_API
123     ValueType::size_type
124     getLength() const;
125    
126    
127     ESCRIPT_DLL_API
128     DataAbstract*
129     getSlice(const DataTypes::RegionType& region) const;
130    
131    
132     DataTypes::ValueType::size_type
133     getPointOffset(int sampleNo,
134     int dataPointNo) const;
135    
136 jfenwick 1879
137     ESCRIPT_DLL_API
138     int
139     getBuffsRequired() const;
140    
141 jfenwick 1865 private:
142 jfenwick 1879 DataReady_ptr m_id;
143     DataLazy_ptr m_left, m_right;
144 jfenwick 1865 ES_optype m_op;
145 jfenwick 1879 size_t m_length; // number of values represented by the operation
146    
147     int m_buffsRequired; // how many buffers are required to evaluate this expression
148     size_t m_samplesize; // number of values required to store a sample
149    
150 jfenwick 1884 const double*
151 jfenwick 1879 resolveSample(ValueType& v,int sampleNo, size_t offset ) const;
152    
153 jfenwick 1886 void
154     intoString(std::ostringstream& oss) const;
155    
156 jfenwick 1865 };
157    
158     }
159     #endif

  ViewVC Help
Powered by ViewVC 1.1.26