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

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

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

trunk/escript/src/Data.h revision 1327 by matt, Fri Oct 12 07:10:40 2007 UTC temp/escript/src/Data.h revision 1387 by trankine, Fri Jan 11 07:45:26 2008 UTC
# Line 533  class Data { Line 533  class Data {
533    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
534                 int dataPointNo)                 int dataPointNo)
535    {    {
536          return m_data->getDataPoint(sampleNo,dataPointNo);                  return m_data->getDataPoint(sampleNo,dataPointNo);
537    }    }
538    
539    /**    /**
# Line 588  class Data { Line 588  class Data {
588    /**    /**
589       \brief       \brief
590       Assign the given value to the tag. Implicitly converts this       Assign the given value to the tag. Implicitly converts this
591       object to type DataTagged. Throws an exception if this object       object to type DataTagged if it is constant.
592       cannot be converted to a DataTagged object.  
593       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
594       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
595      ==>*      ==>*
# Line 602  class Data { Line 602  class Data {
602    /**    /**
603       \brief       \brief
604       Assign the given value to the tag. Implicitly converts this       Assign the given value to the tag. Implicitly converts this
605       object to type DataTagged. Throws an exception if this object       object to type DataTagged if it is constant.
606       cannot be converted to a DataTagged object.  
607       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
608       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
609      ==>*      ==>*
# Line 1201  class Data { Line 1201  class Data {
1201    ESCRIPT_DLL_API    ESCRIPT_DLL_API
1202    inline    inline
1203    void    void
1204    unaryOp(UnaryFunction operation);    unaryOp2(UnaryFunction operation);
1205    
1206    /**    /**
1207       \brief       \brief
# Line 1256  class Data { Line 1256  class Data {
1256    */    */
1257    ESCRIPT_DLL_API    ESCRIPT_DLL_API
1258    void    void
1259      print(void);          print(void);
1260    
1261    /**    /**
1262       \brief       \brief
1263       return the MPI rank number of the local data       return the MPI rank number of the local data
1264           MPI_COMM_WORLD is assumed and the result of MPI_Comm_size()                   MPI_COMM_WORLD is assumed and the result of MPI_Comm_size()
1265           is returned                   is returned
1266    */    */
1267    ESCRIPT_DLL_API    ESCRIPT_DLL_API
1268      int          int
1269      get_MPIRank(void) const;          get_MPIRank(void) const;
1270    
1271    /**    /**
1272       \brief       \brief
1273       return the MPI rank number of the local data       return the MPI rank number of the local data
1274           MPI_COMM_WORLD is assumed and the result of MPI_Comm_rank()                   MPI_COMM_WORLD is assumed and the result of MPI_Comm_rank()
1275           is returned                   is returned
1276    */    */
1277    ESCRIPT_DLL_API    ESCRIPT_DLL_API
1278      int          int
1279      get_MPISize(void) const;          get_MPISize(void) const;
1280    
1281    /**    /**
1282       \brief       \brief
1283       return the MPI rank number of the local data       return the MPI rank number of the local data
1284           MPI_COMM_WORLD is assumed and returned.                   MPI_COMM_WORLD is assumed and returned.
1285    */    */
1286    ESCRIPT_DLL_API    ESCRIPT_DLL_API
1287      MPI_Comm          MPI_Comm
1288      get_MPIComm(void) const;          get_MPIComm(void) const;
1289    
1290    /**    /**
1291       \brief       \brief
1292       return the object produced by the factory, which is a DataConstant or DataExpanded       return the object produced by the factory, which is a DataConstant or DataExpanded
1293    */    */
1294    ESCRIPT_DLL_API    ESCRIPT_DLL_API
1295      DataAbstract*          DataAbstract*
1296      borrowData(void) const;          borrowData(void) const;
1297    
1298   protected:   protected:
1299    
# Line 1543  template <typename BinaryFunction> Line 1543  template <typename BinaryFunction>
1543  ESCRIPT_DLL_API  ESCRIPT_DLL_API
1544  Data  Data
1545  C_TensorBinaryOperation(Data const &arg0,  C_TensorBinaryOperation(Data const &arg0,
1546              Data const &arg1,                          Data const &arg1,
1547              BinaryFunction operation);                          BinaryFunction operation);
1548    
1549  /**  /**
1550    \brief    \brief
# Line 1624  Data::binaryOp(const Data& right, Line 1624  Data::binaryOp(const Data& right,
1624    
1625  /**  /**
1626    \brief    \brief
   Perform the given unary operation on other and return the result.  
   Given operation is performed on each element of each data point, thus  
   argument object is a rank n Data object, and returned object is a rank n  
   Data object.  
   Calls Data::unaryOp.  
 */  
 template <class UnaryFunction>  
 inline  
 Data  
 unaryOp(const Data& other,  
         UnaryFunction operation)  
 {  
   Data result;  
   result.copy(other);  
   result.unaryOp(operation);  
   return result;  
 }  
   
 /**  
   \brief  
   Perform the given unary operation on this.  
   Given operation is performed on each element of each data point.  
   Calls escript::unaryOp.  
 */  
 template <class UnaryFunction>  
 inline  
 void  
 Data::unaryOp(UnaryFunction operation)  
 {  
   if (isExpanded()) {  
     DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());  
     EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");  
     escript::unaryOp(*leftC,operation);  
   } else if (isTagged()) {  
     DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());  
     EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");  
     escript::unaryOp(*leftC,operation);  
   } else if (isConstant()) {  
     DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());  
     EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");  
     escript::unaryOp(*leftC,operation);  
   }  
 }  
   
 /**  
   \brief  
1627    Perform the given Data object reduction algorithm on this and return the result.    Perform the given Data object reduction algorithm on this and return the result.
1628    Given operation combines each element of each data point, thus argument    Given operation combines each element of each data point, thus argument
1629    object (*this) is a rank n Data object, and returned object is a scalar.    object (*this) is a rank n Data object, and returned object is a scalar.
# Line 1752  Data::dp_algorithm(BinaryFunction operat Line 1706  Data::dp_algorithm(BinaryFunction operat
1706  template <typename BinaryFunction>  template <typename BinaryFunction>
1707  Data  Data
1708  C_TensorBinaryOperation(Data const &arg_0,  C_TensorBinaryOperation(Data const &arg_0,
1709              Data const &arg_1,                          Data const &arg_1,
1710              BinaryFunction operation)                          BinaryFunction operation)
1711  {  {
1712    // Interpolate if necessary and find an appropriate function space    // Interpolate if necessary and find an appropriate function space
1713    Data arg_0_Z, arg_1_Z;    Data arg_0_Z, arg_1_Z;
# Line 1787  C_TensorBinaryOperation(Data const &arg_ Line 1741  C_TensorBinaryOperation(Data const &arg_
1741    if (shape0 == shape1) {    if (shape0 == shape1) {
1742    
1743      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {
1744        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());  // DataConstant output        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());      // DataConstant output
1745        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);
1746        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[0]);        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[0]);
1747        double *ptr_2 = &((res.getPointDataView().getData())[0]);        double *ptr_2 = &((res.getPointDataView().getData())[0]);
# Line 1802  C_TensorBinaryOperation(Data const &arg_ Line 1756  C_TensorBinaryOperation(Data const &arg_
1756        DataTagged* tmp_1=dynamic_cast<DataTagged*>(arg_1_Z.borrowData());        DataTagged* tmp_1=dynamic_cast<DataTagged*>(arg_1_Z.borrowData());
1757    
1758        // Prepare a DataTagged output 2        // Prepare a DataTagged output 2
1759        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());  // DataTagged output        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());      // DataTagged output
1760        res.tag();        res.tag();
1761        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
1762    
# Line 1821  C_TensorBinaryOperation(Data const &arg_ Line 1775  C_TensorBinaryOperation(Data const &arg_
1775        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();
1776        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory
1777        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
1778      tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());
1779      DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
1780      DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
1781      double *ptr_1 = &view_1.getData(0);          double *ptr_1 = &view_1.getData(0);
1782      double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);
1783      tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1784        }        }
1785    
1786      }      }
# Line 1843  C_TensorBinaryOperation(Data const &arg_ Line 1797  C_TensorBinaryOperation(Data const &arg_
1797        int offset_0 = tmp_0->getPointOffset(0,0);        int offset_0 = tmp_0->getPointOffset(0,0);
1798        #pragma omp parallel for private(sampleNo_1,dataPointNo_1) schedule(static)        #pragma omp parallel for private(sampleNo_1,dataPointNo_1) schedule(static)
1799        for (sampleNo_1 = 0; sampleNo_1 < numSamples_1; sampleNo_1++) {        for (sampleNo_1 = 0; sampleNo_1 < numSamples_1; sampleNo_1++) {
1800      for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {          for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {
1801        int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);
1802        int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);
1803        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
1804        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
1805        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
1806        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1807      }          }
1808        }        }
1809    
1810      }      }
# Line 1863  C_TensorBinaryOperation(Data const &arg_ Line 1817  C_TensorBinaryOperation(Data const &arg_
1817        DataConstant* tmp_1=dynamic_cast<DataConstant*>(arg_1_Z.borrowData());        DataConstant* tmp_1=dynamic_cast<DataConstant*>(arg_1_Z.borrowData());
1818    
1819        // Prepare a DataTagged output 2        // Prepare a DataTagged output 2
1820        res = Data(0.0, shape0, arg_0_Z.getFunctionSpace());  // DataTagged output        res = Data(0.0, shape0, arg_0_Z.getFunctionSpace());      // DataTagged output
1821        res.tag();        res.tag();
1822        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
1823    
# Line 1882  C_TensorBinaryOperation(Data const &arg_ Line 1836  C_TensorBinaryOperation(Data const &arg_
1836        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
1837        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory
1838        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
1839      tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());
1840      DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
1841      DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
1842      double *ptr_0 = &view_0.getData(0);          double *ptr_0 = &view_0.getData(0);
1843      double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);
1844      tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1845        }        }
1846    
1847      }      }
# Line 1901  C_TensorBinaryOperation(Data const &arg_ Line 1855  C_TensorBinaryOperation(Data const &arg_
1855    
1856        // Prepare a DataTagged output 2        // Prepare a DataTagged output 2
1857        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());
1858        res.tag();    // DataTagged output        res.tag();        // DataTagged output
1859        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
1860    
1861        // Get the views        // Get the views
# Line 1919  C_TensorBinaryOperation(Data const &arg_ Line 1873  C_TensorBinaryOperation(Data const &arg_
1873        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
1874        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();
1875        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
1876      tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue()); // use tmp_2 to get correct shape          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue()); // use tmp_2 to get correct shape
1877        }        }
1878        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
1879      tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());
1880        }        }
1881        // Compute a result for each tag        // Compute a result for each tag
1882        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();
1883        for (i=lookup_2.begin();i!=lookup_2.end();i++) {        for (i=lookup_2.begin();i!=lookup_2.end();i++) {
1884      DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
1885      DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
1886      DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
1887      double *ptr_0 = &view_0.getData(0);          double *ptr_0 = &view_0.getData(0);
1888      double *ptr_1 = &view_1.getData(0);          double *ptr_1 = &view_1.getData(0);
1889      double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);
1890      tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1891        }        }
1892    
1893      }      }
# Line 1950  C_TensorBinaryOperation(Data const &arg_ Line 1904  C_TensorBinaryOperation(Data const &arg_
1904        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();
1905        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
1906        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
1907      int offset_0 = tmp_0->getPointOffset(sampleNo_0,0); // They're all the same, so just use #0          int offset_0 = tmp_0->getPointOffset(sampleNo_0,0); // They're all the same, so just use #0
1908      double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);          double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
1909      for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
1910        int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);
1911        int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
1912        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
1913        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
1914        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1915      }          }
1916        }        }
1917    
1918      }      }
# Line 1975  C_TensorBinaryOperation(Data const &arg_ Line 1929  C_TensorBinaryOperation(Data const &arg_
1929        int offset_1 = tmp_1->getPointOffset(0,0);        int offset_1 = tmp_1->getPointOffset(0,0);
1930        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
1931        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
1932      for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
1933        int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
1934        int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
1935        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
1936        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
1937        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
1938        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1939      }          }
1940        }        }
1941    
1942      }      }
# Line 1999  C_TensorBinaryOperation(Data const &arg_ Line 1953  C_TensorBinaryOperation(Data const &arg_
1953        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();
1954        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
1955        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
1956      int offset_1 = tmp_1->getPointOffset(sampleNo_0,0);          int offset_1 = tmp_1->getPointOffset(sampleNo_0,0);
1957      double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);          double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
1958      for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
1959        int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
1960        int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
1961        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
1962        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
1963        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1964      }          }
1965        }        }
1966    
1967      }      }
# Line 2024  C_TensorBinaryOperation(Data const &arg_ Line 1978  C_TensorBinaryOperation(Data const &arg_
1978        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();
1979        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
1980        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
1981      for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
1982        int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
1983        int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);
1984        int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
1985        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
1986        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
1987        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
1988        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1989      }          }
1990        }        }
1991    
1992      }      }
# Line 2043  C_TensorBinaryOperation(Data const &arg_ Line 1997  C_TensorBinaryOperation(Data const &arg_
1997    } else if (0 == rank0) {    } else if (0 == rank0) {
1998    
1999      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {
2000        res = Data(0.0, shape1, arg_1_Z.getFunctionSpace());  // DataConstant output        res = Data(0.0, shape1, arg_1_Z.getFunctionSpace());      // DataConstant output
2001        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);
2002        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[0]);        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[0]);
2003        double *ptr_2 = &((res.getPointDataView().getData())[0]);        double *ptr_2 = &((res.getPointDataView().getData())[0]);
# Line 2058  C_TensorBinaryOperation(Data const &arg_ Line 2012  C_TensorBinaryOperation(Data const &arg_
2012        DataTagged* tmp_1=dynamic_cast<DataTagged*>(arg_1_Z.borrowData());        DataTagged* tmp_1=dynamic_cast<DataTagged*>(arg_1_Z.borrowData());
2013    
2014        // Prepare a DataTagged output 2        // Prepare a DataTagged output 2
2015        res = Data(0.0, shape1, arg_1_Z.getFunctionSpace());  // DataTagged output        res = Data(0.0, shape1, arg_1_Z.getFunctionSpace());      // DataTagged output
2016        res.tag();        res.tag();
2017        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2018    
# Line 2077  C_TensorBinaryOperation(Data const &arg_ Line 2031  C_TensorBinaryOperation(Data const &arg_
2031        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();
2032        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory
2033        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2034      tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());
2035      DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
2036      DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2037      double *ptr_1 = &view_1.getData(0);          double *ptr_1 = &view_1.getData(0);
2038      double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);
2039      tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2040        }        }
2041    
2042      }      }
# Line 2099  C_TensorBinaryOperation(Data const &arg_ Line 2053  C_TensorBinaryOperation(Data const &arg_
2053        int offset_0 = tmp_0->getPointOffset(0,0);        int offset_0 = tmp_0->getPointOffset(0,0);
2054        #pragma omp parallel for private(sampleNo_1,dataPointNo_1) schedule(static)        #pragma omp parallel for private(sampleNo_1,dataPointNo_1) schedule(static)
2055        for (sampleNo_1 = 0; sampleNo_1 < numSamples_1; sampleNo_1++) {        for (sampleNo_1 = 0; sampleNo_1 < numSamples_1; sampleNo_1++) {
2056      for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {          for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {
2057        int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);
2058        int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);
2059        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2060        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2061        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2062        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2063    
2064      }          }
2065        }        }
2066    
2067      }      }
# Line 2120  C_TensorBinaryOperation(Data const &arg_ Line 2074  C_TensorBinaryOperation(Data const &arg_
2074        DataConstant* tmp_1=dynamic_cast<DataConstant*>(arg_1_Z.borrowData());        DataConstant* tmp_1=dynamic_cast<DataConstant*>(arg_1_Z.borrowData());
2075    
2076        // Prepare a DataTagged output 2        // Prepare a DataTagged output 2
2077        res = Data(0.0, shape1, arg_0_Z.getFunctionSpace());  // DataTagged output        res = Data(0.0, shape1, arg_0_Z.getFunctionSpace());      // DataTagged output
2078        res.tag();        res.tag();
2079        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2080    
# Line 2139  C_TensorBinaryOperation(Data const &arg_ Line 2093  C_TensorBinaryOperation(Data const &arg_
2093        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
2094        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory
2095        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2096      tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());
2097      DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2098      DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2099      double *ptr_0 = &view_0.getData(0);          double *ptr_0 = &view_0.getData(0);
2100      double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);
2101      tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2102        }        }
2103    
2104      }      }
# Line 2158  C_TensorBinaryOperation(Data const &arg_ Line 2112  C_TensorBinaryOperation(Data const &arg_
2112    
2113        // Prepare a DataTagged output 2        // Prepare a DataTagged output 2
2114        res = Data(0.0, shape1, arg_1_Z.getFunctionSpace());        res = Data(0.0, shape1, arg_1_Z.getFunctionSpace());
2115        res.tag();    // DataTagged output        res.tag();        // DataTagged output
2116        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2117    
2118        // Get the views        // Get the views
# Line 2176  C_TensorBinaryOperation(Data const &arg_ Line 2130  C_TensorBinaryOperation(Data const &arg_
2130        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
2131        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();
2132        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2133      tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue()); // use tmp_2 to get correct shape          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue()); // use tmp_2 to get correct shape
2134        }        }
2135        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2136      tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());
2137        }        }
2138        // Compute a result for each tag        // Compute a result for each tag
2139        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();
2140        for (i=lookup_2.begin();i!=lookup_2.end();i++) {        for (i=lookup_2.begin();i!=lookup_2.end();i++) {
2141      DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2142      DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
2143      DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2144      double *ptr_0 = &view_0.getData(0);          double *ptr_0 = &view_0.getData(0);
2145      double *ptr_1 = &view_1.getData(0);          double *ptr_1 = &view_1.getData(0);
2146      double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);
2147      tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2148        }        }
2149    
2150      }      }
# Line 2207  C_TensorBinaryOperation(Data const &arg_ Line 2161  C_TensorBinaryOperation(Data const &arg_
2161        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();
2162        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2163        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2164      int offset_0 = tmp_0->getPointOffset(sampleNo_0,0); // They're all the same, so just use #0          int offset_0 = tmp_0->getPointOffset(sampleNo_0,0); // They're all the same, so just use #0
2165      double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);          double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2166      for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2167        int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);
2168        int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2169        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2170        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2171        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2172      }          }
2173        }        }
2174    
2175      }      }
# Line 2232  C_TensorBinaryOperation(Data const &arg_ Line 2186  C_TensorBinaryOperation(Data const &arg_
2186        int offset_1 = tmp_1->getPointOffset(0,0);        int offset_1 = tmp_1->getPointOffset(0,0);
2187        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2188        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2189      for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2190        int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2191        int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2192        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2193        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2194        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2195        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2196      }          }
2197        }        }
2198    
2199    
# Line 2257  C_TensorBinaryOperation(Data const &arg_ Line 2211  C_TensorBinaryOperation(Data const &arg_
2211        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();
2212        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2213        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2214      int offset_1 = tmp_1->getPointOffset(sampleNo_0,0);          int offset_1 = tmp_1->getPointOffset(sampleNo_0,0);
2215      double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);          double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2216      for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2217        int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2218        int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2219        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2220        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2221        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2222      }          }
2223        }        }
2224    
2225      }      }
# Line 2282  C_TensorBinaryOperation(Data const &arg_ Line 2236  C_TensorBinaryOperation(Data const &arg_
2236        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();
2237        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2238        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2239      for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2240        int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2241        int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);
2242        int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2243        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2244        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2245        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2246        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2247      }          }
2248        }        }
2249    
2250      }      }
# Line 2301  C_TensorBinaryOperation(Data const &arg_ Line 2255  C_TensorBinaryOperation(Data const &arg_
2255    } else if (0 == rank1) {    } else if (0 == rank1) {
2256    
2257      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {
2258        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());  // DataConstant output        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());      // DataConstant output
2259        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);
2260        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[0]);        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[0]);
2261        double *ptr_2 = &((res.getPointDataView().getData())[0]);        double *ptr_2 = &((res.getPointDataView().getData())[0]);
# Line 2316  C_TensorBinaryOperation(Data const &arg_ Line 2270  C_TensorBinaryOperation(Data const &arg_
2270        DataTagged* tmp_1=dynamic_cast<DataTagged*>(arg_1_Z.borrowData());        DataTagged* tmp_1=dynamic_cast<DataTagged*>(arg_1_Z.borrowData());
2271    
2272        // Prepare a DataTagged output 2        // Prepare a DataTagged output 2
2273        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());  // DataTagged output        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());      // DataTagged output
2274        res.tag();        res.tag();
2275        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2276    
# Line 2335  C_TensorBinaryOperation(Data const &arg_ Line 2289  C_TensorBinaryOperation(Data const &arg_
2289        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();
2290        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory
2291        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2292      tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());
2293      DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
2294      DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2295      double *ptr_1 = &view_1.getData(0);          double *ptr_1 = &view_1.getData(0);
2296      double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);
2297      tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2298        }        }
2299    
2300      }      }
# Line 2357  C_TensorBinaryOperation(Data const &arg_ Line 2311  C_TensorBinaryOperation(Data const &arg_
2311        int offset_0 = tmp_0->getPointOffset(0,0);        int offset_0 = tmp_0->getPointOffset(0,0);
2312        #pragma omp parallel for private(sampleNo_1,dataPointNo_1) schedule(static)        #pragma omp parallel for private(sampleNo_1,dataPointNo_1) schedule(static)
2313        for (sampleNo_1 = 0; sampleNo_1 < numSamples_1; sampleNo_1++) {        for (sampleNo_1 = 0; sampleNo_1 < numSamples_1; sampleNo_1++) {
2314      for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {          for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {
2315        int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);
2316        int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);
2317        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2318        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2319        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2320        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2321      }          }
2322        }        }
2323    
2324      }      }
# Line 2377  C_TensorBinaryOperation(Data const &arg_ Line 2331  C_TensorBinaryOperation(Data const &arg_
2331        DataConstant* tmp_1=dynamic_cast<DataConstant*>(arg_1_Z.borrowData());        DataConstant* tmp_1=dynamic_cast<DataConstant*>(arg_1_Z.borrowData());
2332    
2333        // Prepare a DataTagged output 2        // Prepare a DataTagged output 2
2334        res = Data(0.0, shape0, arg_0_Z.getFunctionSpace());  // DataTagged output        res = Data(0.0, shape0, arg_0_Z.getFunctionSpace());      // DataTagged output
2335        res.tag();        res.tag();
2336        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2337    
# Line 2396  C_TensorBinaryOperation(Data const &arg_ Line 2350  C_TensorBinaryOperation(Data const &arg_
2350        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
2351        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory
2352        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2353      tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());
2354      DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2355      DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2356      double *ptr_0 = &view_0.getData(0);          double *ptr_0 = &view_0.getData(0);
2357      double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);
2358      tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2359        }        }
2360    
2361      }      }
# Line 2415  C_TensorBinaryOperation(Data const &arg_ Line 2369  C_TensorBinaryOperation(Data const &arg_
2369    
2370        // Prepare a DataTagged output 2        // Prepare a DataTagged output 2
2371        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());
2372        res.tag();    // DataTagged output        res.tag();        // DataTagged output
2373        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2374    
2375        // Get the views        // Get the views
# Line 2433  C_TensorBinaryOperation(Data const &arg_ Line 2387  C_TensorBinaryOperation(Data const &arg_
2387        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
2388        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();
2389        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2390      tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue()); // use tmp_2 to get correct shape          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue()); // use tmp_2 to get correct shape
2391        }        }
2392        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2393      tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());
2394        }        }
2395        // Compute a result for each tag        // Compute a result for each tag
2396        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();
2397        for (i=lookup_2.begin();i!=lookup_2.end();i++) {        for (i=lookup_2.begin();i!=lookup_2.end();i++) {
2398      DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2399      DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
2400      DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2401      double *ptr_0 = &view_0.getData(0);          double *ptr_0 = &view_0.getData(0);
2402      double *ptr_1 = &view_1.getData(0);          double *ptr_1 = &view_1.getData(0);
2403      double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);
2404      tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2405        }        }
2406    
2407      }      }
# Line 2464  C_TensorBinaryOperation(Data const &arg_ Line 2418  C_TensorBinaryOperation(Data const &arg_
2418        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();
2419        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2420        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2421      int offset_0 = tmp_0->getPointOffset(sampleNo_0,0); // They're all the same, so just use #0          int offset_0 = tmp_0->getPointOffset(sampleNo_0,0); // They're all the same, so just use #0
2422      double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);          double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2423      for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2424        int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);
2425        int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2426        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2427        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2428        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2429      }          }
2430        }        }
2431    
2432      }      }
# Line 2489  C_TensorBinaryOperation(Data const &arg_ Line 2443  C_TensorBinaryOperation(Data const &arg_
2443        int offset_1 = tmp_1->getPointOffset(0,0);        int offset_1 = tmp_1->getPointOffset(0,0);
2444        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2445        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2446      for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2447        int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2448        int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2449        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2450        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2451        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2452        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2453      }          }
2454        }        }
2455    
2456    
# Line 2514  C_TensorBinaryOperation(Data const &arg_ Line 2468  C_TensorBinaryOperation(Data const &arg_
2468        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();
2469        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2470        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2471      int offset_1 = tmp_1->getPointOffset(sampleNo_0,0);          int offset_1 = tmp_1->getPointOffset(sampleNo_0,0);
2472      double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);          double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2473      for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2474        int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2475        int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2476        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2477        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2478        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2479      }          }
2480        }        }
2481    
2482      }      }
# Line 2539  C_TensorBinaryOperation(Data const &arg_ Line 2493  C_TensorBinaryOperation(Data const &arg_
2493        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();
2494        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2495        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2496      for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2497        int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2498        int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);
2499        int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2500        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2501        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2502        double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2503        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2504      }          }
2505        }        }
2506    
2507      }      }
# Line 2560  C_TensorBinaryOperation(Data const &arg_ Line 2514  C_TensorBinaryOperation(Data const &arg_
2514    }    }
2515    
2516    return res;    return res;
2517    }
2518    
2519    template <typename UnaryFunction>
2520    Data
2521    C_TensorUnaryOperation(Data const &arg_0,
2522                           UnaryFunction operation)
2523    {
2524      // Interpolate if necessary and find an appropriate function space
2525      Data arg_0_Z = Data(arg_0);
2526    
2527      // Get rank and shape of inputs
2528      int rank0 = arg_0_Z.getDataPointRank();
2529      DataArrayView::ShapeType shape0 = arg_0_Z.getDataPointShape();
2530      int size0 = arg_0_Z.getDataPointSize();
2531    
2532      // Declare output Data object
2533      Data res;
2534    
2535      if (arg_0_Z.isConstant()) {
2536        res = Data(0.0, shape0, arg_0_Z.getFunctionSpace());      // DataConstant output
2537        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);
2538        double *ptr_2 = &((res.getPointDataView().getData())[0]);
2539        tensor_unary_operation(size0, ptr_0, ptr_2, operation);
2540      }
2541      else if (arg_0_Z.isTagged()) {
2542    
2543        // Borrow DataTagged input from Data object
2544        DataTagged* tmp_0=dynamic_cast<DataTagged*>(arg_0_Z.borrowData());
2545    
2546        // Prepare a DataTagged output 2
2547        res = Data(0.0, shape0, arg_0_Z.getFunctionSpace());   // DataTagged output
2548        res.tag();
2549        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2550    
2551        // Get the views
2552        DataArrayView view_0 = tmp_0->getDefaultValue();
2553        DataArrayView view_2 = tmp_2->getDefaultValue();
2554        // Get the pointers to the actual data
2555        double *ptr_0 = &((view_0.getData())[0]);
2556        double *ptr_2 = &((view_2.getData())[0]);
2557        // Compute a result for the default
2558        tensor_unary_operation(size0, ptr_0, ptr_2, operation);
2559        // Compute a result for each tag
2560        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
2561        DataTagged::DataMapType::const_iterator i; // i->first is a tag, i->second is an offset into memory
2562        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2563          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());
2564          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2565          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2566          double *ptr_0 = &view_0.getData(0);
2567          double *ptr_2 = &view_2.getData(0);
2568          tensor_unary_operation(size0, ptr_0, ptr_2, operation);
2569        }
2570    
2571      }
2572      else if (arg_0_Z.isExpanded()) {
2573    
2574        res = Data(0.0, shape0, arg_0_Z.getFunctionSpace(),true); // DataExpanded output
2575        DataExpanded* tmp_0=dynamic_cast<DataExpanded*>(arg_0_Z.borrowData());
2576        DataExpanded* tmp_2=dynamic_cast<DataExpanded*>(res.borrowData());
2577    
2578        int sampleNo_0,dataPointNo_0;
2579        int numSamples_0 = arg_0_Z.getNumSamples();
2580        int numDataPointsPerSample_0 = arg_0_Z.getNumDataPointsPerSample();
2581        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2582        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2583          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2584            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2585            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2586            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2587            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2588            tensor_unary_operation(size0, ptr_0, ptr_2, operation);
2589          }
2590        }
2591    
2592      }
2593      else {
2594        throw DataException("Error - C_TensorUnaryOperation: unknown combination of inputs");
2595      }
2596    
2597      return res;
2598  }  }
2599    
2600  }  }

Legend:
Removed from v.1327  
changed lines
  Added in v.1387

  ViewVC Help
Powered by ViewVC 1.1.26