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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1898 by jfenwick, Mon Oct 20 01:20:18 2008 UTC revision 1899 by jfenwick, Mon Oct 20 05:13:24 2008 UTC
# Line 17  Line 17 
17  #include "system_dep.h"  #include "system_dep.h"
18    
19  #include "DataAbstract.h"  #include "DataAbstract.h"
 //#include "DataTypes.h"  
 //#include "FunctionSpace.h"  
20    
21  #include <string>  #include <string>
22  #include <functional>  #include <functional>
# Line 87  typedef DataTypes::ValueType ValueType; Line 85  typedef DataTypes::ValueType ValueType;
85  typedef DataTypes::ShapeType ShapeType;  typedef DataTypes::ShapeType ShapeType;
86    
87  public:  public:
88      /**
89      \brief Create an IDENTITY DataLazy for the given DataAbstract.
90      \param p DataAbstract to be wrapped.
91      \throws DataException if p is lazy data or it is not constant, tagged or expanded.
92      */
93    ESCRIPT_DLL_API    ESCRIPT_DLL_API
94    DataLazy(DataAbstract_ptr p);    DataLazy(DataAbstract_ptr p);
95    
   ESCRIPT_DLL_API  
   DataLazy(DataAbstract_ptr left, ES_optype op);  
   
96    
97  /*    /**
98      \brief Produce a DataLazy for a unary operation.
99      \param left DataAbstract to be operated on.
100      \param op unary operation to perform.
101      \throws DataException if op is not a unary operation or if p cannot be converted to a DataLazy.
102      Note that IDENTITY is not considered a unary operation.
103      */
104    ESCRIPT_DLL_API    ESCRIPT_DLL_API
105    DataLazy(DataLazy_ptr left, DataLazy_ptr right, ES_optype op);*/    DataLazy(DataAbstract_ptr left, ES_optype op);
106    
107      /**
108      \brief Produce a DataLazy for a binary operation.
109      \param left left operand
110      \param right right operand
111      \param op unary operation to perform.
112      \throws DataException if op is not a binary operation or if left or right cannot be converted to a DataLazy.
113      */
114    ESCRIPT_DLL_API    ESCRIPT_DLL_API
115    DataLazy(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op);    DataLazy(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op);
116    
117    ESCRIPT_DLL_API    ESCRIPT_DLL_API
118    ~DataLazy();    ~DataLazy();
119    
   
   
120    /**    /**
121    \brief Compute all data points in the expression tree    \brief Evaluate the lazy expression.
122      \return A DataReady with the value of the lazy expresion.
123    */    */
124    ESCRIPT_DLL_API    ESCRIPT_DLL_API
125    DataReady_ptr    DataReady_ptr
# Line 141  public: Line 153  public:
153                   int dataPointNo) const;                   int dataPointNo) const;
154    
155    
156      /**
157        \return the number of samples which need to be stored to evaluate the expression.
158      */
159    ESCRIPT_DLL_API    ESCRIPT_DLL_API
160    int    int
161    getBuffsRequired() const;    getBuffsRequired() const;
# Line 148  public: Line 163  public:
163    
164    
165  private:  private:
166    DataReady_ptr m_id;    DataReady_ptr m_id;   //  For IDENTITY nodes, stores a wrapped value.
167    DataLazy_ptr m_left, m_right;    DataLazy_ptr m_left, m_right; // operands for operation.
168    ES_optype m_op;    ES_optype m_op;   // operation to perform.
169    size_t m_length;  // number of values represented by the operation    size_t m_length;  // number of values represented by the operation
170    
171    int m_buffsRequired;  // how many buffers are required to evaluate this expression    int m_buffsRequired;  // how many samples are required to evaluate this expression
172    size_t m_samplesize;  // number of values required to store a sample    size_t m_samplesize;  // number of values required to store a sample
173    
174    const ValueType*    char m_readytype; // E for expanded, T for tagged, C for constant
   resolveSample(ValueType& v,  size_t offset ,int sampleNo, size_t& roffset);  
   
 //   const double*  
 //   resolveSample(ValueType& v,int sampleNo,  size_t offset );  
 /*  
   const double*  
   resolveSample2(ValueType& v,int sampleNo,  size_t offset );*/  
175    
176    
177      /**
178      Does the work for toString.
179      */
180    void    void
181    intoString(std::ostringstream& oss) const;    intoString(std::ostringstream& oss) const;
182    
183    char m_readytype;    /**
184       \brief Converts the DataLazy into an IDENTITY storing the value of the expression.
185       This method uses the original methods on the Data class to evaluate the expressions.
186       For this reason, it should not be used on DataExpanded instances. (To do so would defeat
187       the purpose of using DataLazy in the first place).
188      */
189    void    void
190    collapse();       // converts the node into an IDENTITY node    collapse();       // converts the node into an IDENTITY node
191    
192    
193      /**
194      \brief Evaluates the expression using methods on Data.
195      This does the work for the collapse method.
196      For reasons of efficiency do not call this method on DataExpanded nodes.
197      */
198    DataReady_ptr    DataReady_ptr
199    collapseToReady();    collapseToReady();
200    
201  //   const double*    /**
202  //   resolveUnary(ValueType& v,int sampleNo,  size_t offset) const;    \brief Compute the value of the expression for the given sample.
203  //    \return Vector which stores the value of the subexpression for the given sample.
204  //   const double*    \param v A vector to store intermediate results.
205  //   resolveBinary(ValueType& v,int sampleNo,  size_t offset) const;    \param offset Index in v to begin storing results.
206      \param sampleNo Sample number to evaluate.
207      \param roffset (output parameter) the offset in the return vector where the result begins.
208    
209      The return value will be an existing vector so do not deallocate it.
210      */
211      const ValueType*
212      resolveSample(ValueType& v,  size_t offset ,int sampleNo, size_t& roffset);
213    
214      /**
215      \brief Compute the value of the expression (binary operation) for the given sample.
216      \return Vector which stores the value of the subexpression for the given sample.
217      \param v A vector to store intermediate results.
218      \param offset Index in v to begin storing results.
219      \param sampleNo Sample number to evaluate.
220      \param roffset (output parameter) the offset in the return vector where the result begins.
221    
222      The return value will be an existing vector so do not deallocate it.
223      If the result is stored in v it should be stored at the offset given.
224      Everything from offset to the end of v should be considered available for this method to use.
225      */
226    ValueType*    ValueType*
227    resolveUnary(ValueType& v,  size_t offset,int sampleNo,  size_t& roffset) const;    resolveUnary(ValueType& v,  size_t offset,int sampleNo,  size_t& roffset) const;
228    
229      /**
230      \brief Compute the value of the expression (binary operation) for the given sample.
231      \return Vector which stores the value of the subexpression for the given sample.
232      \param v A vector to store intermediate results.
233      \param offset Index in v to begin storing results.
234      \param sampleNo Sample number to evaluate.
235      \param roffset (output parameter) the offset in the return vector where the result begins.
236    
237      The return value will be an existing vector so do not deallocate it.
238      If the result is stored in v it should be stored at the offset given.
239      Everything from offset to the end of v should be considered available for this method to use.
240      */
241    ValueType*    ValueType*
242    resolveBinary(ValueType& v,  size_t offset,int sampleNo,  size_t& roffset) const;    resolveBinary(ValueType& v,  size_t offset,int sampleNo,  size_t& roffset) const;
243    

Legend:
Removed from v.1898  
changed lines
  Added in v.1899

  ViewVC Help
Powered by ViewVC 1.1.26