/[escript]/branches/clazy/escriptcore/src/DataLazy.cpp
ViewVC logotype

Diff of /branches/clazy/escriptcore/src/DataLazy.cpp

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

revision 1901 by jfenwick, Wed Oct 22 02:44:34 2008 UTC revision 1908 by jfenwick, Thu Oct 23 01:35:31 2008 UTC
# Line 136  resultShape(DataAbstract_ptr left, DataA Line 136  resultShape(DataAbstract_ptr left, DataA
136  {  {
137      if (left->getShape()!=right->getShape())      if (left->getShape()!=right->getShape())
138      {      {
139          throw DataException("Shapes not the same - shapes must match for lazy data.");        if (getOpgroup(op)!=G_BINARY)
140          {
141            throw DataException("Shapes not the name - shapes must match for (point)binary operations.");
142          }
143          if (left->getRank()==0)   // we need to allow scalar * anything
144          {
145            return right->getShape();
146          }
147          if (right->getRank()==0)
148          {
149            return left->getShape();
150          }
151          throw DataException("Shapes not the same - arguments must have matching shapes (or be scalars) for (point)binary operations on lazy data.");
152      }      }
153      return left->getShape();      return left->getShape();
154  }  }
# Line 576  DataLazy::resolveUnary(ValueType& v, siz Line 588  DataLazy::resolveUnary(ValueType& v, siz
588    
589    
590  #define PROC_OP(X) \  #define PROC_OP(X) \
591      for (int i=0;i<steps;++i,resultp+=getNoValues()) \      for (int i=0;i<steps;++i,resultp+=resultStep) \
592      { \      { \
593         tensor_binary_operation(chunksize, &((*left)[lroffset]), &((*right)[rroffset]), resultp, X); \         tensor_binary_operation(chunksize, &((*left)[lroffset]), &((*right)[rroffset]), resultp, X); \
594         lroffset+=leftStep; \         lroffset+=leftStep; \
# Line 601  DataLazy::resolveUnary(ValueType& v, siz Line 613  DataLazy::resolveUnary(ValueType& v, siz
613  // the whole sample as one big datapoint.  // the whole sample as one big datapoint.
614  // If one of the children is not expanded, then we need to treat each point in the sample  // If one of the children is not expanded, then we need to treat each point in the sample
615  // individually.  // individually.
616    // There is an additional complication when scalar operations are considered.
617    // For example, 2+Vector.
618    // In this case each double within the point is treated individually
619  DataTypes::ValueType*  DataTypes::ValueType*
620  DataLazy::resolveBinary(ValueType& v,  size_t offset, int sampleNo, size_t& roffset) const  DataLazy::resolveBinary(ValueType& v,  size_t offset, int sampleNo, size_t& roffset) const
621  {  {
# Line 611  cout << "Resolve binary: " << toString() Line 626  cout << "Resolve binary: " << toString()
626    bool leftExp=(m_left->m_readytype=='E');    bool leftExp=(m_left->m_readytype=='E');
627    bool rightExp=(m_right->m_readytype=='E');    bool rightExp=(m_right->m_readytype=='E');
628    bool bigloops=((leftExp && rightExp) || (!leftExp && !rightExp)); // is processing in single step?    bool bigloops=((leftExp && rightExp) || (!leftExp && !rightExp)); // is processing in single step?
629    int steps=(bigloops?1:getNumDPPSample());        int steps=(bigloops?1:getNumDPPSample());
630    size_t chunksize=(bigloops? m_samplesize : getNoValues());    // if bigloops, pretend the whole sample is a datapoint    size_t chunksize=(bigloops? m_samplesize : getNoValues());    // if bigloops, pretend the whole sample is a datapoint
631    int leftStep=((leftExp && !rightExp)? getNoValues() : 0);    if (m_left->getRank()!=m_right->getRank())    // need to deal with scalar * ? ops
632    int rightStep=((rightExp && !leftExp)? getNoValues() : 0);    {
633        EsysAssert((m_left->getRank()==0) || (m_right->getRank()==0), "Error - Ranks must match unless one is 0.");
634        steps=getNumDPPSample()*max(m_left->getNoValues(),m_right->getNoValues());
635        chunksize=1;    // for scalar
636      }    
637      int leftStep=((leftExp && !rightExp)? m_right->getNoValues() : 0);
638      int rightStep=((rightExp && !leftExp)? m_left->getNoValues() : 0);
639      int resultStep=max(leftStep,rightStep);   // only one (at most) should be !=0
640      // Get the values of sub-expressions      // Get the values of sub-expressions
641    const ValueType* left=m_left->resolveSample(v,offset,sampleNo,lroffset);    const ValueType* left=m_left->resolveSample(v,offset,sampleNo,lroffset);
642    const ValueType* right=m_right->resolveSample(v,offset+m_samplesize,sampleNo,rroffset); // Note    const ValueType* right=m_right->resolveSample(v,offset+m_samplesize,sampleNo,rroffset); // Note

Legend:
Removed from v.1901  
changed lines
  Added in v.1908

  ViewVC Help
Powered by ViewVC 1.1.26