/[escript]/branches/schroedinger_upto1946/escript/src/DataLazy.cpp
ViewVC logotype

Diff of /branches/schroedinger_upto1946/escript/src/DataLazy.cpp

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

revision 1865 by jfenwick, Thu Oct 9 03:53:57 2008 UTC revision 1868 by jfenwick, Thu Oct 9 06:30:49 2008 UTC
# Line 21  Line 21 
21  #endif  #endif
22  #include "FunctionSpace.h"  #include "FunctionSpace.h"
23  #include "DataTypes.h"  #include "DataTypes.h"
24    #include "Data.h"
25    
26  using namespace std;  using namespace std;
27    using namespace boost;
28    
29  namespace escript  namespace escript
30  {  {
# Line 57  resultLength(DataAbstract_ptr left, Data Line 59  resultLength(DataAbstract_ptr left, Data
59     switch(op)     switch(op)
60     {     {
61     case IDENTITY: return left->getLength();     case IDENTITY: return left->getLength();
62       case ADD:    // the length is preserved in these ops
63       case SUB:
64       case MUL:
65       case DIV: return left->getLength();
66     default:     default:
67      throw DataException("Programmer Error - attempt to getLength() for operator "+opToString(op)+".");      throw DataException("Programmer Error - attempt to getLength() for operator "+opToString(op)+".");
68    
69     }     }
70  }  }
71    
72  string ES_opstrings[]={"UNKNOWN","IDENTITY"};  string ES_opstrings[]={"UNKNOWN","IDENTITY","+","-","*","/"};
73  int ES_opcount=2;  int ES_opcount=5;
74    
75  }   // end anonymous namespace  }   // end anonymous namespace
76    
# Line 97  DataLazy::DataLazy(DataAbstract_ptr left Line 103  DataLazy::DataLazy(DataAbstract_ptr left
103     length=resultLength(m_left,m_right,m_op);     length=resultLength(m_left,m_right,m_op);
104  }  }
105    
   
106  DataLazy::~DataLazy()  DataLazy::~DataLazy()
107  {  {
108  }  }
# Line 106  DataLazy::~DataLazy() Line 111  DataLazy::~DataLazy()
111  DataReady_ptr  DataReady_ptr
112  DataLazy::resolve()  DataLazy::resolve()
113  {  {
114    if (m_op==IDENTITY)    DataReady_ptr left;
115      DataReady_ptr right;
116      if (m_left.get()!=0)
117      {
118        left=m_left->resolve();
119      }
120      if (m_right.get()!=0)
121    {    {
122      return m_left->resolve();      right=m_right->resolve();
123    }    }
124    else    switch (m_op)
125    {    {
126      throw DataException("Programmer error - do not know how to resolve operator "+opToString(m_op)+".");      case IDENTITY: return left;
127        case ADD:
128        // Hmm we could get interpolation here, better be careful
129          return C_TensorBinaryOperation(Data(left),Data(right),plus<double>()).borrowReadyPtr();
130        case SUB:
131          return C_TensorBinaryOperation(Data(left),Data(right),minus<double>()).borrowReadyPtr();
132        case MUL:
133          return C_TensorBinaryOperation(Data(left),Data(right),multiplies<double>()).borrowReadyPtr();
134        case DIV:
135          return C_TensorBinaryOperation(Data(left),Data(right),divides<double>()).borrowReadyPtr();
136        default:
137        throw DataException("Programmer error - do not know how to resolve operator "+opToString(m_op)+".");
138    }    }
139  }  }
140    

Legend:
Removed from v.1865  
changed lines
  Added in v.1868

  ViewVC Help
Powered by ViewVC 1.1.26