/[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 1884 - (hide annotations)
Tue Oct 14 04:54:59 2008 UTC (11 years, 7 months ago) by jfenwick
File MIME type: text/plain
File size: 2866 byte(s)
Branch commit
Not crashing.

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     DIV=5
38 jfenwick 1865 };
39    
40     const std::string&
41     opToString(ES_optype op);
42    
43     /**
44     \class escript::DataLazy
45     \brief Wraps an expression tree of other DataObjects.
46     The values of DataPoints are computed when requested rather than all at once.
47 jfenwick 1879
48     NOTE: This class assumes that the Data being pointed at are immutable.
49 jfenwick 1865 */
50    
51 jfenwick 1879 class DataLazy;
52    
53     typedef POINTER_WRAPPER_CLASS(DataLazy) DataLazy_ptr;
54     typedef POINTER_WRAPPER_CLASS(const DataLazy) const_DataLazy_ptr;
55    
56 jfenwick 1865 class DataLazy : public DataAbstract
57     {
58    
59     typedef DataAbstract parent;
60     typedef DataTypes::ValueType ValueType;
61     typedef DataTypes::ShapeType ShapeType;
62    
63     public:
64     ESCRIPT_DLL_API
65     DataLazy(DataAbstract_ptr p);
66    
67     ESCRIPT_DLL_API
68 jfenwick 1879 DataLazy(DataLazy_ptr left, DataLazy_ptr right, ES_optype op);
69    
70     ESCRIPT_DLL_API
71 jfenwick 1865 DataLazy(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op);
72    
73     ESCRIPT_DLL_API
74     ~DataLazy();
75    
76    
77    
78     /**
79     \brief Compute all data points in the expression tree
80     */
81     ESCRIPT_DLL_API
82 jfenwick 1879 DataReady_ptr
83     resolve();
84 jfenwick 1865
85     ESCRIPT_DLL_API
86     std::string
87     toString() const;
88    
89     ESCRIPT_DLL_API
90     DataAbstract*
91     deepCopy();
92    
93    
94     /**
95     \brief
96     Return the number of doubles that would be stored for this Data object if it were resolved.
97     */
98     ESCRIPT_DLL_API
99     ValueType::size_type
100     getLength() const;
101    
102    
103     ESCRIPT_DLL_API
104     DataAbstract*
105     getSlice(const DataTypes::RegionType& region) const;
106    
107    
108     DataTypes::ValueType::size_type
109     getPointOffset(int sampleNo,
110     int dataPointNo) const;
111    
112 jfenwick 1879
113     // // this is a top level function, the actual searching will be done by helper methods
114     // ESCRIPT_DLL_API
115     // void
116     // getSample(ValueType& v, int sampleNo,size_t offset=0) const;
117    
118     ESCRIPT_DLL_API
119     int
120     getBuffsRequired() const;
121    
122 jfenwick 1865 private:
123 jfenwick 1879 DataReady_ptr m_id;
124     DataLazy_ptr m_left, m_right;
125 jfenwick 1865 ES_optype m_op;
126 jfenwick 1879 size_t m_length; // number of values represented by the operation
127    
128     int m_buffsRequired; // how many buffers are required to evaluate this expression
129     size_t m_samplesize; // number of values required to store a sample
130    
131 jfenwick 1884 const double*
132 jfenwick 1879 resolveSample(ValueType& v,int sampleNo, size_t offset ) const;
133    
134 jfenwick 1865 };
135    
136     }
137     #endif

  ViewVC Help
Powered by ViewVC 1.1.26