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

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

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

branches/schroedinger/escript/src/DataLazy.h revision 1903 by jfenwick, Wed Oct 22 06:11:01 2008 UTC trunk/escript/src/DataLazy.h revision 2084 by jfenwick, Fri Nov 21 05:20:42 2008 UTC
# Line 25  Line 25 
25    
26  namespace escript {  namespace escript {
27    
28    // For the purposes of unit testing and maintaining sanity, it is important that this enum be contiguous
29  enum ES_optype  enum ES_optype
30  {  {
31      UNKNOWNOP=0,      UNKNOWNOP=0,
# Line 33  enum ES_optype Line 34  enum ES_optype
34      SUB=3,      SUB=3,
35      MUL=4,      MUL=4,
36      DIV=5,      DIV=5,
37      SIN=6,      POW=6,
38      COS=7,      SIN=POW+1,
39      TAN=8,      COS=SIN+1,
40      ASIN=9,      TAN=SIN+2,
41      ACOS=10,      ASIN=SIN+3,
42      ATAN=11,      ACOS=SIN+4,
43      SINH=12,      ATAN=SIN+5,
44      COSH=13,      SINH=SIN+6,
45      TANH=14,      COSH=SIN+7,
46      ERF=15,      TANH=SIN+8,
47      ASINH=16,      ERF=SIN+9,
48      ACOSH=17,      ASINH=SIN+10,
49      ATANH=18,      ACOSH=SIN+11,
50      LOG10=19,      ATANH=SIN+12,
51      LOG=20,      LOG10=ATANH+1,
52      SIGN=21,      LOG=LOG10+1,
53      ABS=22,      SIGN=LOG10+2,
54      NEG=23,      ABS=LOG10+3,
55      POS=24,      NEG=LOG10+4,
56      EXP=25,      POS=LOG10+5,
57      SQRT=26,      EXP=LOG10+6,
58      RECIP=27,      SQRT=LOG10+7,
59      GZ=28,      RECIP=LOG10+8,
60      LZ=29,      GZ=RECIP+1,
61      GEZ=30,      LZ=GZ+1,
62      LEZ=31      GEZ=GZ+2,
63        LEZ=GZ+3,
64        SYM=LEZ+1,
65        NSYM=SYM+1,
66        PROD=NSYM+1,
67        TRANS=PROD+1,
68        TRACE=TRANS+1
69  };  };
70    
71    ESCRIPT_DLL_API
72  const std::string&  const std::string&
73  opToString(ES_optype op);  opToString(ES_optype op);
74    
# Line 106  public: Line 114  public:
114    DataLazy(DataAbstract_ptr left, ES_optype op);    DataLazy(DataAbstract_ptr left, ES_optype op);
115    
116    /**    /**
117      \brief Produce a DataLazy for a unary operation which requires a parameter.
118      \param left DataAbstract to be operated on.
119      \param op unary operation to perform.
120      \param axis_offset the parameter for the operation
121      \throws DataException if op is not a unary operation or if p cannot be converted to a DataLazy.
122      Note that IDENTITY is not considered a unary operation.
123      */
124      ESCRIPT_DLL_API  
125      DataLazy(DataAbstract_ptr left, ES_optype op, int axis_offset);
126    
127    
128      /**
129    \brief Produce a DataLazy for a binary operation.    \brief Produce a DataLazy for a binary operation.
130    \param left left operand    \param left left operand
131    \param right right operand    \param right right operand
# Line 115  public: Line 135  public:
135    ESCRIPT_DLL_API    ESCRIPT_DLL_API
136    DataLazy(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op);    DataLazy(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op);
137    
138      /**
139      \brief Produce a DataLazy for a binary operation with additional paramters.
140      \param left left operand
141      \param right right operand
142      \param op unary operation to perform.
143      \param axis_offset
144      \param transpose  
145      \throws DataException if op is not a binary operation requiring parameters or if left or right cannot be converted to a DataLazy.
146      */
147      ESCRIPT_DLL_API
148      DataLazy(DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op, int axis_offset, int transpose);
149    
150    ESCRIPT_DLL_API    ESCRIPT_DLL_API
151    ~DataLazy();    ~DataLazy();
152    
# Line 137  public: Line 169  public:
169    
170    /**    /**
171       \brief       \brief
172       Return the number of doubles that would be stored for this Data object if it were resolved.       This method throws an exception. It does not really make sense to ask this question of lazy data.
173    */    */
174    ESCRIPT_DLL_API    ESCRIPT_DLL_API
175    ValueType::size_type    ValueType::size_type
# Line 153  public: Line 185  public:
185    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
186                   int dataPointNo) const;                   int dataPointNo) const;
187    
188      DataTypes::ValueType::size_type
189      getPointOffset(int sampleNo,
190                     int dataPointNo);
191    
192    
193    /**    /**
194      \return the number of samples which need to be stored to evaluate the expression.      \return the number of samples which need to be stored to evaluate the expression.
# Line 162  public: Line 198  public:
198    getBuffsRequired() const;    getBuffsRequired() const;
199    
200    /**    /**
201        \return the largest samplesize required to evaluate the expression.
202      */
203      ESCRIPT_DLL_API
204      size_t
205      getMaxSampleSize() const;
206    
207    
208      /**
209       \brief Produces an IDENTITY DataLazy containing zero.       \brief Produces an IDENTITY DataLazy containing zero.
210       The result will have the same shape and functionspace as before.       The result will have the same shape and functionspace as before.
211    */    */
# Line 173  private: Line 217  private:
217    DataReady_ptr m_id;   //  For IDENTITY nodes, stores a wrapped value.    DataReady_ptr m_id;   //  For IDENTITY nodes, stores a wrapped value.
218    DataLazy_ptr m_left, m_right; // operands for operation.    DataLazy_ptr m_left, m_right; // operands for operation.
219    ES_optype m_op;   // operation to perform.    ES_optype m_op;   // operation to perform.
   size_t m_length;  // number of values represented by the operation  
220    
221    int m_buffsRequired;  // how many samples are required to evaluate this expression    int m_buffsRequired;  // how many samples are required to evaluate this expression
222    size_t m_samplesize;  // number of values required to store a sample    size_t m_samplesize;  // number of values required to store a sample
223    
224    char m_readytype; // E for expanded, T for tagged, C for constant    char m_readytype; // E for expanded, T for tagged, C for constant
225    
226      int m_axis_offset;    // required extra info for general tensor product
227      int m_transpose;
228      int m_SL, m_SM, m_SR; // computed properties used in general tensor product
229    
230      unsigned int m_maxsamplesize; // largest samplesize required by any node in the expression
231    
232    
233    /**    /**
234    Does the work for toString.    Does the work for toString.
# Line 219  private: Line 268  private:
268    resolveSample(ValueType& v,  size_t offset ,int sampleNo, size_t& roffset);    resolveSample(ValueType& v,  size_t offset ,int sampleNo, size_t& roffset);
269    
270    /**    /**
271    \brief Compute the value of the expression (binary operation) for the given sample.    \brief Compute the value of the expression (unary operation) for the given sample.
272    \return Vector which stores the value of the subexpression for the given sample.    \return Vector which stores the value of the subexpression for the given sample.
273    \param v A vector to store intermediate results.    \param v A vector to store intermediate results.
274    \param offset Index in v to begin storing results.    \param offset Index in v to begin storing results.
# Line 234  private: Line 283  private:
283    resolveUnary(ValueType& v,  size_t offset,int sampleNo,  size_t& roffset) const;    resolveUnary(ValueType& v,  size_t offset,int sampleNo,  size_t& roffset) const;
284    
285    /**    /**
286      \brief Compute the value of the expression (unary non-pointwise operation) for the given sample.
287      \return Vector which stores the value of the subexpression for the given sample.
288      \param v A vector to store intermediate results.
289      \param offset Index in v to begin storing results.
290      \param sampleNo Sample number to evaluate.
291      \param roffset (output parameter) the offset in the return vector where the result begins.
292    
293      The return value will be an existing vector so do not deallocate it.
294      If the result is stored in v it should be stored at the offset given.
295      Everything from offset to the end of v should be considered available for this method to use.
296    
297      This method differs from the one above in that deals with operations that are not
298      point-wise. That is, the answer cannot just be written on top of the input.
299      Extra buffers are required for these operations.
300      */
301    
302      ValueType*
303      resolveNP1OUT(ValueType& v, size_t offset, int sampleNo, size_t& roffset) const;
304    
305    /**
306      \brief Compute the value of the expression (unary operation) for the given sample.
307      \return Vector which stores the value of the subexpression for the given sample.
308      \param v A vector to store intermediate results.
309      \param offset Index in v to begin storing results.
310      \param sampleNo Sample number to evaluate.
311      \param roffset (output parameter) the offset in the return vector where the result begins.
312    
313      The return value will be an existing vector so do not deallocate it.
314      If the result is stored in v it should be stored at the offset given.
315      Everything from offset to the end of v should be considered available for this method to use.
316    */
317    DataTypes::ValueType*
318    resolveNP1OUT_P(ValueType& v, size_t offset, int sampleNo, size_t& roffset) const;
319    
320    
321      /**
322    \brief Compute the value of the expression (binary operation) for the given sample.    \brief Compute the value of the expression (binary operation) for the given sample.
323    \return Vector which stores the value of the subexpression for the given sample.    \return Vector which stores the value of the subexpression for the given sample.
324    \param v A vector to store intermediate results.    \param v A vector to store intermediate results.
# Line 248  private: Line 333  private:
333    ValueType*    ValueType*
334    resolveBinary(ValueType& v,  size_t offset,int sampleNo,  size_t& roffset) const;    resolveBinary(ValueType& v,  size_t offset,int sampleNo,  size_t& roffset) const;
335    
336      /**
337      \brief Compute the value of the expression (tensor product) for the given sample.
338      \return Vector which stores the value of the subexpression for the given sample.
339      \param v A vector to store intermediate results.
340      \param offset Index in v to begin storing results.
341      \param sampleNo Sample number to evaluate.
342      \param roffset (output parameter) the offset in the return vector where the result begins.
343    
344      The return value will be an existing vector so do not deallocate it.
345      If the result is stored in v it should be stored at the offset given.
346      Everything from offset to the end of v should be considered available for this method to use.
347      */
348      DataTypes::ValueType*
349      resolveTProd(ValueType& v,  size_t offset, int sampleNo, size_t& roffset) const;
350    
351  };  };
352    
353  }  }

Legend:
Removed from v.1903  
changed lines
  Added in v.2084

  ViewVC Help
Powered by ViewVC 1.1.26