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

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

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

revision 1748 by ksteube, Wed Sep 3 06:10:39 2008 UTC revision 1796 by jfenwick, Wed Sep 17 01:45:46 2008 UTC
# Line 25  Line 25 
25  #include "BinaryOp.h"  #include "BinaryOp.h"
26  #include "UnaryOp.h"  #include "UnaryOp.h"
27  #include "DataException.h"  #include "DataException.h"
28    #include "DataTypes.h"
29    
30  extern "C" {  extern "C" {
31  #include "DataC.h"  #include "DataC.h"
# Line 103  class Data { Line 104  class Data {
104         const FunctionSpace& what);         const FunctionSpace& what);
105    
106    /**    /**
107       \brief      \brief Copy Data from an existing vector
108       Constructor which copies data from a DataArrayView.    */
109    
      \param value - Input - Data value for a single point.  
      \param what - Input - A description of what this data represents.  
      \param expanded - Input - Flag, if true fill the entire container with  
                        the value. Otherwise a more efficient storage  
                        mechanism will be used.  
   */  
110    ESCRIPT_DLL_API    ESCRIPT_DLL_API
111    Data(const DataArrayView& value,    Data(const DataTypes::ValueType& value,
112         const FunctionSpace& what=FunctionSpace(),           const DataTypes::ShapeType& shape,
113         bool expanded=false);                   const FunctionSpace& what=FunctionSpace(),
114                     bool expanded=false);
115    
116    /**    /**
117       \brief       \brief
# Line 130  class Data { Line 126  class Data {
126    */    */
127    ESCRIPT_DLL_API    ESCRIPT_DLL_API
128    Data(double value,    Data(double value,
129         const DataArrayView::ShapeType& dataPointShape=DataArrayView::ShapeType(),         const DataTypes::ShapeType& dataPointShape=DataTypes::ShapeType(),
130         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
131         bool expanded=false);         bool expanded=false);
132    
# Line 143  class Data { Line 139  class Data {
139    */    */
140    ESCRIPT_DLL_API    ESCRIPT_DLL_API
141    Data(const Data& inData,    Data(const Data& inData,
142         const DataArrayView::RegionType& region);         const DataTypes::RegionType& region);
   
   /**  
      \brief  
      Constructor which will create Tagged data if expanded is false.  
      No attempt is made to ensure the tag keys match the tag keys  
      within the function space.  
   
      \param tagKeys - Input - List of tag values.  
      \param values - Input - List of values, one for each tag.  
      \param defaultValue - Input - A default value, used if tag doesn't exist.  
      \param what - Input - A description of what this data represents.  
      \param expanded - Input - Flag, if true fill the entire container with  
                        the appropriate values.  
     ==>*  
   */  
   ESCRIPT_DLL_API  
   Data(const DataTagged::TagListType& tagKeys,  
        const DataTagged::ValueListType& values,  
        const DataArrayView& defaultValue,  
        const FunctionSpace& what=FunctionSpace(),  
        bool expanded=false);  
143    
144    /**    /**
145       \brief       \brief
# Line 219  class Data { Line 194  class Data {
194         const boost::python::tuple& shape=boost::python::make_tuple(),         const boost::python::tuple& shape=boost::python::make_tuple(),
195         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
196         bool expanded=false);         bool expanded=false);
197    
198    
199    
200      /**
201        \brief Create a Data using an existing DataAbstract. Warning: The new object assumes ownership of the pointer!
202        Once you have passed the pointer, do not delete it.
203      */
204      ESCRIPT_DLL_API
205      Data(DataAbstract* underlyingdata);
206    
207    
208    /**    /**
209       \brief       \brief
210       Destructor       Destructor
# Line 313  class Data { Line 299  class Data {
299    escriptDataC    escriptDataC
300    getDataC();    getDataC();
301    
302    
303    
304    
305    
306    
307    // REMOVE ME
308    // ESCRIPT_DLL_API
309    // void
310    // CompareDebug(const Data& rd);
311    
312    
313    /**    /**
314       \brief       \brief
315       Return the C wrapper for the Data object - const version.       Return the C wrapper for the Data object - const version.
# Line 330  class Data { Line 327  class Data {
327    toString() const;    toString() const;
328    
329    
330    /**  //  /**
331       \brief  /*     \brief
332       Return the DataArrayView of the point data. This essentially contains       Return the DataArrayView of the point data. This essentially contains
333       the shape information for each data point although it also may be used       the shape information for each data point although it also may be used
334       to manipulate the point data.       to manipulate the point data.*/
335    */  //  */
336    ESCRIPT_DLL_API  //   ESCRIPT_DLL_API
337    inline  //   inline
338    const DataArrayView&  //   const DataArrayView&
339    getPointDataView() const  //   getPointDataView() const
340    {  //   {
341       return m_data->getPointDataView();  //      return m_data->getPointDataView();
342    }  //   }
343    
344    /**    /**
345       \brief       \brief
# Line 444  class Data { Line 441  class Data {
441    int    int
442    getDataPointRank() const    getDataPointRank() const
443    {    {
444      return m_data->getPointDataView().getRank();  //    return m_data->getPointDataView().getRank();
445        return m_data->getRank();
446    }    }
447    
448    /**    /**
# Line 481  class Data { Line 479  class Data {
479    {    {
480      return m_data->getNumDPPSample();      return m_data->getNumDPPSample();
481    }    }
482    
483    
484      /**
485        \brief
486        Return the number of values in the shape for this object.
487      */
488      ESCRIPT_DLL_API
489      int
490      getNoValues() const
491      {
492        return m_data->getNoValues();
493      }
494    
495    
496    /**    /**
497       \brief       \brief
498       dumps the object into a netCDF file       dumps the object into a netCDF file
# Line 516  class Data { Line 528  class Data {
528      return m_data->getSampleDataByTag(tag);      return m_data->getSampleDataByTag(tag);
529    }    }
530    
531    //  /**
532    /*     \brief
533         Return a view into the data for the data point specified.
534         NOTE: Construction of the DataArrayView is a relatively expensive
535         operation.
536         \param sampleNo - Input -
537         \param dataPointNo - Input -*/
538    //  */
539    //   ESCRIPT_DLL_API
540    //   inline
541    //   DataArrayView
542    //   getDataPoint(int sampleNo,
543    //                int dataPointNo)
544    //   {
545    //                 return m_data->getDataPoint(sampleNo,dataPointNo);
546    //   }
547    
548    
549    /**    /**
550       \brief       \brief
551       Return a view into the data for the data point specified.       Return a view into the data for the data point specified.
# Line 525  class Data { Line 555  class Data {
555       \param dataPointNo - Input -       \param dataPointNo - Input -
556    */    */
557    ESCRIPT_DLL_API    ESCRIPT_DLL_API
558      DataTypes::ValueType::const_reference
559      getDataPoint(int sampleNo, int dataPointNo) const;
560    
561    
562      ESCRIPT_DLL_API
563      DataTypes::ValueType::reference
564      getDataPoint(int sampleNo, int dataPointNo);
565    
566    
567    
568      /**
569         \brief
570         Return the offset for the given sample and point within the sample
571      */
572      ESCRIPT_DLL_API
573    inline    inline
574    DataArrayView    DataTypes::ValueType::size_type
575    getDataPoint(int sampleNo,    getDataOffset(int sampleNo,
576                 int dataPointNo)                 int dataPointNo)
577    {    {
578                  return m_data->getDataPoint(sampleNo,dataPointNo);                  return m_data->getPointOffset(sampleNo,dataPointNo);
579    }    }
580    
581    /**    /**
# Line 538  class Data { Line 583  class Data {
583       Return a reference to the data point shape.       Return a reference to the data point shape.
584    */    */
585    ESCRIPT_DLL_API    ESCRIPT_DLL_API
586    const DataArrayView::ShapeType&    inline
587    getDataPointShape() const;    const DataTypes::ShapeType&
588      getDataPointShape() const
589      {
590        return m_data->getShape();
591      }
592    
593    /**    /**
594       \brief       \brief
# Line 563  class Data { Line 612  class Data {
612       Return the number of doubles stored for this Data.       Return the number of doubles stored for this Data.
613    */    */
614    ESCRIPT_DLL_API    ESCRIPT_DLL_API
615    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
616    getLength() const;    getLength() const;
617    
618    
# Line 596  class Data { Line 645  class Data {
645    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
646                   const boost::python::object& value);                   const boost::python::object& value);
647    
648    
649    //  /**
650    //     \brief
651    //     Assign the given value to the tag. Implicitly converts this
652    //     object to type DataTagged if it is constant.
653    //
654    //     \param tagKey - Input - Integer key.
655    //     \param value - Input - Value to associate with given key.
656    //    ==>*
657    //  */
658    //   ESCRIPT_DLL_API
659    //   void
660    //   setTaggedValueFromCPP(int tagKey,
661    //                         const DataArrayView& value);
662    
663    /**    /**
664       \brief       \brief
665       Assign the given value to the tag. Implicitly converts this       Assign the given value to the tag. Implicitly converts this
666       object to type DataTagged if it is constant.       object to type DataTagged if it is constant.
667    
668       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
669         \param pointshape - Input - The shape of the value parameter
670       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
671      ==>*       \param dataOffset - Input - Offset of the begining of the point within the value parameter
672    */    */
673    ESCRIPT_DLL_API    ESCRIPT_DLL_API
674    void    void
675    setTaggedValueFromCPP(int tagKey,    setTaggedValueFromCPP(int tagKey,
676                          const DataArrayView& value);              const DataTypes::ShapeType& pointshape,
677                            const DataTypes::ValueType& value,
678                int dataOffset=0);
679    
680    
681    
682    /**    /**
683      \brief      \brief
# Line 1209  class Data { Line 1278  class Data {
1278    */    */
1279    ESCRIPT_DLL_API    ESCRIPT_DLL_API
1280    Data    Data
1281    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
1282    
1283    /**    /**
1284       \brief       \brief
# Line 1222  class Data { Line 1291  class Data {
1291    ESCRIPT_DLL_API    ESCRIPT_DLL_API
1292    void    void
1293    setSlice(const Data& value,    setSlice(const Data& value,
1294             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
   
   /**  
      \brief  
      Archive the current Data object to the given file.  
      \param fileName - Input - file to archive to.  
   */  
   ESCRIPT_DLL_API  
   void  
   archiveData(const std::string fileName);  
   
   /**  
      \brief  
      Extract the Data object archived in the given file, overwriting  
      the current Data object.  
      Note - the current object must be of type DataEmpty.  
      \param fileName - Input - file to extract from.  
      \param fspace - Input - a suitable FunctionSpace descibing the data.  
   */  
   ESCRIPT_DLL_API  
   void  
   extractData(const std::string fileName,  
               const FunctionSpace& fspace);  
   
1295    
1296    /**    /**
1297       \brief       \brief
# Line 1287  class Data { Line 1333  class Data {
1333    /**    /**
1334       \brief       \brief
1335       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
1336        TODO Ownership of this object should be explained in doco.
1337    */    */
1338    ESCRIPT_DLL_API    ESCRIPT_DLL_API
1339          DataAbstract*          DataAbstract*
1340          borrowData(void) const;          borrowData(void) const;
1341    
1342    
1343      /**
1344         \brief
1345         Return a pointer to the beginning of the datapoint at the specified offset.
1346         TODO Eventually these should be inlined.
1347         \param i - position(offset) in the underlying datastructure
1348      */
1349      ESCRIPT_DLL_API
1350            DataTypes::ValueType::const_reference
1351            getDataAtOffset(DataTypes::ValueType::size_type i) const;
1352    
1353    
1354      ESCRIPT_DLL_API
1355            DataTypes::ValueType::reference
1356            getDataAtOffset(DataTypes::ValueType::size_type i);
1357    
1358   protected:   protected:
1359    
1360   private:   private:
# Line 1367  class Data { Line 1430  class Data {
1430       \brief       \brief
1431       Construct a Data object of the appropriate type.       Construct a Data object of the appropriate type.
1432    */    */
1433    template <class IValueType>  
1434    void    void
1435    initialise(const IValueType& value,    initialise(const DataTypes::ValueType& value,
1436             const DataTypes::ShapeType& shape,
1437               const FunctionSpace& what,               const FunctionSpace& what,
1438               bool expanded);               bool expanded);
1439    
1440      void
1441      initialise(const boost::python::numeric::array& value,
1442                     const FunctionSpace& what,
1443                     bool expanded);
1444    
1445    //    //
1446    // flag to protect the data object against any update    // flag to protect the data object against any update
1447    bool m_protected;    bool m_protected;
# Line 1383  class Data { Line 1452  class Data {
1452    
1453  };  };
1454    
1455  template <class IValueType>  
 void  
 Data::initialise(const IValueType& value,  
                  const FunctionSpace& what,  
                  bool expanded)  
 {  
   //  
   // Construct a Data object of the appropriate type.  
   // Construct the object first as there seems to be a bug which causes  
   // undefined behaviour if an exception is thrown during construction  
   // within the shared_ptr constructor.  
   if (expanded) {  
     DataAbstract* temp=new DataExpanded(value,what);  
     boost::shared_ptr<DataAbstract> temp_data(temp);  
     m_data=temp_data;  
   } else {  
     DataAbstract* temp=new DataConstant(value,what);  
     boost::shared_ptr<DataAbstract> temp_data(temp);  
     m_data=temp_data;  
   }  
 }  
1456    
1457  /**  /**
1458     Modify a filename for MPI parallel output to multiple files     Modify a filename for MPI parallel output to multiple files
# Line 1535  C_GeneralTensorProduct(Data& arg0, Line 1584  C_GeneralTensorProduct(Data& arg0,
1584    
1585    
1586    
1587  /**  // /**
1588    \brief  /*  \brief
1589    Return true if operands are equivalent, else return false.    Return true if operands are equivalent, else return false.
1590    NB: this operator does very little at this point, and isn't to    NB: this operator does very little at this point, and isn't to
1591    be relied on. Requires further implementation.    be relied on. Requires further implementation.*/
1592  */  //*/
1593  // ESCRIPT_DLL_API bool operator==(const Data& left, const Data& right);  // ESCRIPT_DLL_API bool operator==(const Data& left, const Data& right);
1594    
1595  /**  /**
# Line 1556  Data::binaryOp(const Data& right, Line 1605  Data::binaryOp(const Data& right,
1605  {  {
1606     //     //
1607     // if this has a rank of zero promote it to the rank of the RHS     // if this has a rank of zero promote it to the rank of the RHS
1608     if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) {     if (getDataPointRank()==0 && right.getDataPointRank()!=0) {
1609       throw DataException("Error - attempt to update rank zero object with object with rank bigger than zero.");       throw DataException("Error - attempt to update rank zero object with object with rank bigger than zero.");
1610     }     }
1611     //     //
# Line 1653  Data Line 1702  Data
1702  Data::dp_algorithm(BinaryFunction operation, double initial_value) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1703  {  {
1704    if (isExpanded()) {    if (isExpanded()) {
1705      Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());      Data result(0,DataTypes::ShapeType(),getFunctionSpace(),isExpanded());
1706      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1707      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1708      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
# Line 1662  Data::dp_algorithm(BinaryFunction operat Line 1711  Data::dp_algorithm(BinaryFunction operat
1711      return result;      return result;
1712    } else if (isTagged()) {    } else if (isTagged()) {
1713      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
     DataArrayView::ShapeType viewShape;  
     DataArrayView::ValueType viewData(1);  
     viewData[0]=0;  
     DataArrayView defaultValue(viewData,viewShape);  
     DataTagged::TagListType keys;  
     DataTagged::ValueListType values;  
     DataTagged::DataMapType::const_iterator i;  
     for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) {  
       keys.push_back(i->first);  
       values.push_back(defaultValue);  
     }  
     Data result(keys,values,defaultValue,getFunctionSpace());  
     DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());  
1714      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1715      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");  
1716    //     DataTypes::ShapeType viewShape;
1717    //     DataTypes::ValueType viewData(1);
1718    //     viewData[0]=0;
1719    //     DataArrayView defaultValue(viewData,viewShape);
1720    //     DataTagged::TagListType keys;
1721    //     DataTagged::ValueListType values;
1722    //     DataTagged::DataMapType::const_iterator i;
1723    //     for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) {
1724    //       keys.push_back(i->first);
1725    //       values.push_back(defaultValue);
1726    //     }
1727    //     Data result(keys,values,defaultValue,getFunctionSpace());
1728    //     DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1729    //     EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1730    
1731    
1732    
1733    
1734        DataTypes::ValueType defval(1);
1735        defval[0]=0;
1736        DataTagged* resultT=new DataTagged(getFunctionSpace(), DataTypes::scalarShape, defval, dataT);
1737      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1738      return result;      return Data(resultT);   // note: the Data object now owns the resultT pointer
1739    
1740    } else if (isConstant()) {    } else if (isConstant()) {
1741      Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());      Data result(0,DataTypes::ShapeType(),getFunctionSpace(),isExpanded());
1742      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1743      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1744      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
# Line 1727  C_TensorBinaryOperation(Data const &arg_ Line 1785  C_TensorBinaryOperation(Data const &arg_
1785    // Get rank and shape of inputs    // Get rank and shape of inputs
1786    int rank0 = arg_0_Z.getDataPointRank();    int rank0 = arg_0_Z.getDataPointRank();
1787    int rank1 = arg_1_Z.getDataPointRank();    int rank1 = arg_1_Z.getDataPointRank();
1788    DataArrayView::ShapeType shape0 = arg_0_Z.getDataPointShape();    DataTypes::ShapeType shape0 = arg_0_Z.getDataPointShape();
1789    DataArrayView::ShapeType shape1 = arg_1_Z.getDataPointShape();    DataTypes::ShapeType shape1 = arg_1_Z.getDataPointShape();
1790    int size0 = arg_0_Z.getDataPointSize();    int size0 = arg_0_Z.getDataPointSize();
1791    int size1 = arg_1_Z.getDataPointSize();    int size1 = arg_1_Z.getDataPointSize();
1792    
# Line 1739  C_TensorBinaryOperation(Data const &arg_ Line 1797  C_TensorBinaryOperation(Data const &arg_
1797    
1798      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {
1799        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());      // DataConstant output        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());      // DataConstant output
1800        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);  /*      double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);
1801        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[0]);        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[0]);
1802        double *ptr_2 = &((res.getPointDataView().getData())[0]);        double *ptr_2 = &((res.getPointDataView().getData())[0]);*/
1803          double *ptr_0 = &(arg_0_Z.getDataAtOffset(0));
1804          double *ptr_1 = &(arg_1_Z.getDataAtOffset(0));
1805          double *ptr_2 = &(res.getDataAtOffset(0));
1806    
1807        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1808      }      }
1809      else if (arg_0_Z.isConstant()   && arg_1_Z.isTagged()) {      else if (arg_0_Z.isConstant()   && arg_1_Z.isTagged()) {
# Line 1759  C_TensorBinaryOperation(Data const &arg_ Line 1821  C_TensorBinaryOperation(Data const &arg_
1821    
1822        // Prepare offset into DataConstant        // Prepare offset into DataConstant
1823        int offset_0 = tmp_0->getPointOffset(0,0);        int offset_0 = tmp_0->getPointOffset(0,0);
1824        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);        double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
1825        // Get the views        // Get the views
1826        DataArrayView view_1 = tmp_1->getDefaultValue();  //       DataArrayView view_1 = tmp_1->getDefaultValue();
1827        DataArrayView view_2 = tmp_2->getDefaultValue();  //       DataArrayView view_2 = tmp_2->getDefaultValue();
1828    //       // Get the pointers to the actual data
1829    //       double *ptr_1 = &((view_1.getData())[0]);
1830    //       double *ptr_2 = &((view_2.getData())[0]);
1831    
1832        // Get the pointers to the actual data        // Get the pointers to the actual data
1833        double *ptr_1 = &((view_1.getData())[0]);        double *ptr_1 = &(tmp_1->getDefaultValue(0));
1834        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &(tmp_2->getDefaultValue(0));
1835    
1836        // Compute a result for the default        // Compute a result for the default
1837        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1838        // Compute a result for each tag        // Compute a result for each tag
1839        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();
1840        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
1841        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
1842          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTag(i->first);
1843          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);  /*        DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
1844          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
1845          double *ptr_1 = &view_1.getData(0);          double *ptr_1 = &view_1.getData(0);
1846          double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);*/
1847            double *ptr_1 = &(tmp_1->getDataByTag(i->first,0));
1848            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
1849    
1850          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1851        }        }
1852    
# Line 1797  C_TensorBinaryOperation(Data const &arg_ Line 1867  C_TensorBinaryOperation(Data const &arg_
1867          for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {          for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {
1868            int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);
1869            int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);
1870            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);  //           double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
1871            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);  //           double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
1872            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);  //           double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
1873    
1874              double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
1875              double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
1876              double *ptr_2 = &(res.getDataAtOffset(offset_2));
1877            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1878          }          }
1879        }        }
# Line 1820  C_TensorBinaryOperation(Data const &arg_ Line 1894  C_TensorBinaryOperation(Data const &arg_
1894    
1895        // Prepare offset into DataConstant        // Prepare offset into DataConstant
1896        int offset_1 = tmp_1->getPointOffset(0,0);        int offset_1 = tmp_1->getPointOffset(0,0);
1897        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);  //       double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
1898          double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
1899        // Get the views        // Get the views
1900        DataArrayView view_0 = tmp_0->getDefaultValue();  //       DataArrayView view_0 = tmp_0->getDefaultValue();
1901        DataArrayView view_2 = tmp_2->getDefaultValue();  //       DataArrayView view_2 = tmp_2->getDefaultValue();
1902    //       // Get the pointers to the actual data
1903    //       double *ptr_0 = &((view_0.getData())[0]);
1904    //       double *ptr_2 = &((view_2.getData())[0]);
1905        // Get the pointers to the actual data        // Get the pointers to the actual data
1906        double *ptr_0 = &((view_0.getData())[0]);        double *ptr_0 = &(tmp_0->getDefaultValue(0));
1907        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &(tmp_2->getDefaultValue(0));
1908        // Compute a result for the default        // Compute a result for the default
1909        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1910        // Compute a result for each tag        // Compute a result for each tag
1911        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
1912        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
1913        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
1914          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTag(i->first);
1915          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  //         DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
1916          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  //         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
1917          double *ptr_0 = &view_0.getData(0);  //         double *ptr_0 = &view_0.getData(0);
1918          double *ptr_2 = &view_2.getData(0);  //         double *ptr_2 = &view_2.getData(0);
1919            double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
1920            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
1921          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1922        }        }
1923    
# Line 1855  C_TensorBinaryOperation(Data const &arg_ Line 1935  C_TensorBinaryOperation(Data const &arg_
1935        res.tag();        // DataTagged output        res.tag();        // DataTagged output
1936        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
1937    
1938        // Get the views  //       // Get the views
1939        DataArrayView view_0 = tmp_0->getDefaultValue();  //       DataArrayView view_0 = tmp_0->getDefaultValue();
1940        DataArrayView view_1 = tmp_1->getDefaultValue();  //       DataArrayView view_1 = tmp_1->getDefaultValue();
1941        DataArrayView view_2 = tmp_2->getDefaultValue();  //       DataArrayView view_2 = tmp_2->getDefaultValue();
1942    //       // Get the pointers to the actual data
1943    //       double *ptr_0 = &((view_0.getData())[0]);
1944    //       double *ptr_1 = &((view_1.getData())[0]);
1945    //       double *ptr_2 = &((view_2.getData())[0]);
1946    
1947        // Get the pointers to the actual data        // Get the pointers to the actual data
1948        double *ptr_0 = &((view_0.getData())[0]);        double *ptr_0 = &(tmp_0->getDefaultValue(0));
1949        double *ptr_1 = &((view_1.getData())[0]);        double *ptr_1 = &(tmp_1->getDefaultValue(0));
1950        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &(tmp_2->getDefaultValue(0));
1951    
1952        // Compute a result for the default        // Compute a result for the default
1953        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1954        // Merge the tags        // Merge the tags
# Line 1870  C_TensorBinaryOperation(Data const &arg_ Line 1956  C_TensorBinaryOperation(Data const &arg_
1956        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
1957        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();
1958        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
1959          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue()); // use tmp_2 to get correct shape          tmp_2->addTag(i->first); // use tmp_2 to get correct shape
1960        }        }
1961        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
1962          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTag(i->first);
1963        }        }
1964        // Compute a result for each tag        // Compute a result for each tag
1965        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();
1966        for (i=lookup_2.begin();i!=lookup_2.end();i++) {        for (i=lookup_2.begin();i!=lookup_2.end();i++) {
1967          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  
1968          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);  //         DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
1969          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  //         DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
1970          double *ptr_0 = &view_0.getData(0);  //         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
1971          double *ptr_1 = &view_1.getData(0);  //         double *ptr_0 = &view_0.getData(0);
1972          double *ptr_2 = &view_2.getData(0);  //         double *ptr_1 = &view_1.getData(0);
1973    //         double *ptr_2 = &view_2.getData(0);
1974    
1975            double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
1976            double *ptr_1 = &(tmp_1->getDataByTag(i->first,0));
1977            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
1978    
1979          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1980        }        }
1981    
# Line 1902  C_TensorBinaryOperation(Data const &arg_ Line 1994  C_TensorBinaryOperation(Data const &arg_
1994        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
1995        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
1996          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
1997          double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);          double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
1998          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
1999            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);
2000            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2001            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);  
2002            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);  //           double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2003    //           double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2004              double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2005              double *ptr_2 = &(res.getDataAtOffset(offset_2));
2006    
2007    
2008            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
2009          }          }
2010        }        }
# Line 1929  C_TensorBinaryOperation(Data const &arg_ Line 2026  C_TensorBinaryOperation(Data const &arg_
2026          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2027            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2028            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2029            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);  
2030            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);  //           double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2031            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);  //           double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2032    //           double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2033    
2034              double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2035              double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2036              double *ptr_2 = &(res.getDataAtOffset(offset_2));
2037    
2038    
2039            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
2040          }          }
2041        }        }
# Line 1951  C_TensorBinaryOperation(Data const &arg_ Line 2055  C_TensorBinaryOperation(Data const &arg_
2055        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2056        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2057          int offset_1 = tmp_1->getPointOffset(sampleNo_0,0);          int offset_1 = tmp_1->getPointOffset(sampleNo_0,0);
2058          double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);          double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2059          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2060            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2061            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2062            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2063            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &(res.getDataAtOffset(offset_2));
2064            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
2065          }          }
2066        }        }
# Line 1979  C_TensorBinaryOperation(Data const &arg_ Line 2083  C_TensorBinaryOperation(Data const &arg_
2083            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2084            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);
2085            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2086            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2087            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2088            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &(res.getDataAtOffset(offset_2));
2089            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
2090          }          }
2091        }        }
# Line 1995  C_TensorBinaryOperation(Data const &arg_ Line 2099  C_TensorBinaryOperation(Data const &arg_
2099    
2100      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {
2101        res = Data(0.0, shape1, arg_1_Z.getFunctionSpace());      // DataConstant output        res = Data(0.0, shape1, arg_1_Z.getFunctionSpace());      // DataConstant output
2102        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);        double *ptr_0 = &(arg_0_Z.getDataAtOffset(0));
2103        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[0]);        double *ptr_1 = &(arg_1_Z.getDataAtOffset(0));
2104        double *ptr_2 = &((res.getPointDataView().getData())[0]);        double *ptr_2 = &(res.getDataAtOffset(0));
2105        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2106      }      }
2107      else if (arg_0_Z.isConstant()   && arg_1_Z.isTagged()) {      else if (arg_0_Z.isConstant()   && arg_1_Z.isTagged()) {
# Line 2015  C_TensorBinaryOperation(Data const &arg_ Line 2119  C_TensorBinaryOperation(Data const &arg_
2119    
2120        // Prepare offset into DataConstant        // Prepare offset into DataConstant
2121        int offset_0 = tmp_0->getPointOffset(0,0);        int offset_0 = tmp_0->getPointOffset(0,0);
2122        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);        double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2123        // Get the views        // Get the views
2124        DataArrayView view_1 = tmp_1->getDefaultValue();  //       DataArrayView view_1 = tmp_1->getDefaultValue();
2125        DataArrayView view_2 = tmp_2->getDefaultValue();  //       DataArrayView view_2 = tmp_2->getDefaultValue();
2126        // Get the pointers to the actual data  //       // Get the pointers to the actual data
2127        double *ptr_1 = &((view_1.getData())[0]);  //       double *ptr_1 = &((view_1.getData())[0]);
2128        double *ptr_2 = &((view_2.getData())[0]);  //       double *ptr_2 = &((view_2.getData())[0]);
2129           double *ptr_1 = &(tmp_1->getDefaultValue(0));
2130           double *ptr_2 = &(tmp_2->getDefaultValue(0));
2131    
2132        // Compute a result for the default        // Compute a result for the default
2133        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2134        // Compute a result for each tag        // Compute a result for each tag
2135        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();
2136        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
2137        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2138          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTag(i->first);
2139          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);  //         DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
2140          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  //         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2141          double *ptr_1 = &view_1.getData(0);  //         double *ptr_1 = &view_1.getData(0);
2142          double *ptr_2 = &view_2.getData(0);  //         double *ptr_2 = &view_2.getData(0);
2143            double *ptr_1 = &(tmp_1->getDataByTag(i->first,0));
2144            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2145          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2146        }        }
2147    
# Line 2053  C_TensorBinaryOperation(Data const &arg_ Line 2162  C_TensorBinaryOperation(Data const &arg_
2162          for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {          for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {
2163            int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);
2164            int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);
2165            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2166            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2167            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &(res.getDataAtOffset(offset_2));
2168            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2169    
2170          }          }
# Line 2077  C_TensorBinaryOperation(Data const &arg_ Line 2186  C_TensorBinaryOperation(Data const &arg_
2186    
2187        // Prepare offset into DataConstant        // Prepare offset into DataConstant
2188        int offset_1 = tmp_1->getPointOffset(0,0);        int offset_1 = tmp_1->getPointOffset(0,0);
2189        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);  //       double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2190          double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2191        // Get the views        // Get the views
2192        DataArrayView view_0 = tmp_0->getDefaultValue();  /*      DataArrayView view_0 = tmp_0->getDefaultValue();
2193        DataArrayView view_2 = tmp_2->getDefaultValue();        DataArrayView view_2 = tmp_2->getDefaultValue();
2194        // Get the pointers to the actual data        // Get the pointers to the actual data
2195        double *ptr_0 = &((view_0.getData())[0]);        double *ptr_0 = &((view_0.getData())[0]);
2196        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &((view_2.getData())[0]);*/
2197    
2198          // Get the pointers to the actual data
2199          double *ptr_0 = &(tmp_0->getDefaultValue(0));
2200          double *ptr_2 = &(tmp_2->getDefaultValue(0));
2201    
2202    
2203        // Compute a result for the default        // Compute a result for the default
2204        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2205        // Compute a result for each tag        // Compute a result for each tag
2206        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
2207        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
2208        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2209          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTag(i->first);
2210          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  /*        DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2211          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2212          double *ptr_0 = &view_0.getData(0);          double *ptr_0 = &view_0.getData(0);
2213          double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);*/
2214            double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
2215            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2216    
2217          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2218        }        }
2219    
# Line 2113  C_TensorBinaryOperation(Data const &arg_ Line 2232  C_TensorBinaryOperation(Data const &arg_
2232        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2233    
2234        // Get the views        // Get the views
2235        DataArrayView view_0 = tmp_0->getDefaultValue();  /*      DataArrayView view_0 = tmp_0->getDefaultValue();
2236        DataArrayView view_1 = tmp_1->getDefaultValue();        DataArrayView view_1 = tmp_1->getDefaultValue();
2237        DataArrayView view_2 = tmp_2->getDefaultValue();        DataArrayView view_2 = tmp_2->getDefaultValue();
2238        // Get the pointers to the actual data        // Get the pointers to the actual data
2239        double *ptr_0 = &((view_0.getData())[0]);        double *ptr_0 = &((view_0.getData())[0]);
2240        double *ptr_1 = &((view_1.getData())[0]);        double *ptr_1 = &((view_1.getData())[0]);
2241        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &((view_2.getData())[0]);*/
2242    
2243          // Get the pointers to the actual data
2244          double *ptr_0 = &(tmp_0->getDefaultValue(0));
2245          double *ptr_1 = &(tmp_1->getDefaultValue(0));
2246          double *ptr_2 = &(tmp_2->getDefaultValue(0));
2247    
2248    
2249        // Compute a result for the default        // Compute a result for the default
2250        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2251        // Merge the tags        // Merge the tags
# Line 2127  C_TensorBinaryOperation(Data const &arg_ Line 2253  C_TensorBinaryOperation(Data const &arg_
2253        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
2254        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();
2255        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2256          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue()); // use tmp_2 to get correct shape          tmp_2->addTag(i->first); // use tmp_2 to get correct shape
2257        }        }
2258        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2259          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTag(i->first);
2260        }        }
2261        // Compute a result for each tag        // Compute a result for each tag
2262        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();
2263        for (i=lookup_2.begin();i!=lookup_2.end();i++) {        for (i=lookup_2.begin();i!=lookup_2.end();i++) {
2264          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  
2265    /*        DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2266          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
2267          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2268          double *ptr_0 = &view_0.getData(0);          double *ptr_0 = &view_0.getData(0);
2269          double *ptr_1 = &view_1.getData(0);          double *ptr_1 = &view_1.getData(0);
2270          double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);*/
2271    
2272            double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
2273            double *ptr_1 = &(tmp_1->getDataByTag(i->first,0));
2274            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2275    
2276          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2277        }        }
2278    
# Line 2159  C_TensorBinaryOperation(Data const &arg_ Line 2291  C_TensorBinaryOperation(Data const &arg_
2291        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2292        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2293          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
2294          double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);          double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2295          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2296            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);
2297            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2298            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2299            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &(res.getDataAtOffset(offset_2));
2300            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2301          }          }
2302        }        }
# Line 2186  C_TensorBinaryOperation(Data const &arg_ Line 2318  C_TensorBinaryOperation(Data const &arg_
2318          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2319            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2320            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2321            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2322            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2323            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &(res.getDataAtOffset(offset_2));
2324            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2325          }          }
2326        }        }
# Line 2209  C_TensorBinaryOperation(Data const &arg_ Line 2341  C_TensorBinaryOperation(Data const &arg_
2341        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2342        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2343          int offset_1 = tmp_1->getPointOffset(sampleNo_0,0);          int offset_1 = tmp_1->getPointOffset(sampleNo_0,0);
2344          double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);          double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2345          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2346            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2347            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2348            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2349            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &(res.getDataAtOffset(offset_2));
2350            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2351          }          }
2352        }        }
# Line 2237  C_TensorBinaryOperation(Data const &arg_ Line 2369  C_TensorBinaryOperation(Data const &arg_
2369            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2370            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);
2371            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2372            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2373            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2374            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &(res.getDataAtOffset(offset_2));
2375            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);            tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2376          }          }
2377        }        }
# Line 2253  C_TensorBinaryOperation(Data const &arg_ Line 2385  C_TensorBinaryOperation(Data const &arg_
2385    
2386      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {
2387        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());      // DataConstant output        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());      // DataConstant output
2388        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);        double *ptr_0 = &(arg_0_Z.getDataAtOffset(0));
2389        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[0]);        double *ptr_1 = &(arg_1_Z.getDataAtOffset(0));
2390        double *ptr_2 = &((res.getPointDataView().getData())[0]);        double *ptr_2 = &(res.getDataAtOffset(0));
2391        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2392      }      }
2393      else if (arg_0_Z.isConstant()   && arg_1_Z.isTagged()) {      else if (arg_0_Z.isConstant()   && arg_1_Z.isTagged()) {
# Line 2273  C_TensorBinaryOperation(Data const &arg_ Line 2405  C_TensorBinaryOperation(Data const &arg_
2405    
2406        // Prepare offset into DataConstant        // Prepare offset into DataConstant
2407        int offset_0 = tmp_0->getPointOffset(0,0);        int offset_0 = tmp_0->getPointOffset(0,0);
2408        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);        double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2409        // Get the views        // Get the views
2410        DataArrayView view_1 = tmp_1->getDefaultValue();  /*      DataArrayView view_1 = tmp_1->getDefaultValue();
2411        DataArrayView view_2 = tmp_2->getDefaultValue();        DataArrayView view_2 = tmp_2->getDefaultValue();
2412        // Get the pointers to the actual data        // Get the pointers to the actual data
2413        double *ptr_1 = &((view_1.getData())[0]);        double *ptr_1 = &((view_1.getData())[0]);
2414        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &((view_2.getData())[0]);*/
2415          //Get the pointers to the actual data
2416          double *ptr_1 = &(tmp_1->getDefaultValue(0));
2417          double *ptr_2 = &(tmp_2->getDefaultValue(0));
2418    
2419        // Compute a result for the default        // Compute a result for the default
2420        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2421        // Compute a result for each tag        // Compute a result for each tag
2422        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();
2423        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
2424        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2425          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTag(i->first);
2426          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);  //         DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
2427          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  //         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2428          double *ptr_1 = &view_1.getData(0);  //         double *ptr_1 = &view_1.getData(0);
2429          double *ptr_2 = &view_2.getData(0);  //         double *ptr_2 = &view_2.getData(0);
2430            double *ptr_1 = &(tmp_1->getDataByTag(i->first,0));
2431            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2432    
2433    
2434          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2435        }        }
2436    
# Line 2311  C_TensorBinaryOperation(Data const &arg_ Line 2451  C_TensorBinaryOperation(Data const &arg_
2451          for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {          for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {
2452            int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);
2453            int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);
2454            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2455            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2456            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &(res.getDataAtOffset(offset_2));
2457            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2458          }          }
2459        }        }
# Line 2334  C_TensorBinaryOperation(Data const &arg_ Line 2474  C_TensorBinaryOperation(Data const &arg_
2474    
2475        // Prepare offset into DataConstant        // Prepare offset into DataConstant
2476        int offset_1 = tmp_1->getPointOffset(0,0);        int offset_1 = tmp_1->getPointOffset(0,0);
2477        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);        double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2478        // Get the views        // Get the views
2479        DataArrayView view_0 = tmp_0->getDefaultValue();  //       DataArrayView view_0 = tmp_0->getDefaultValue();
2480        DataArrayView view_2 = tmp_2->getDefaultValue();  //       DataArrayView view_2 = tmp_2->getDefaultValue();
2481    //       // Get the pointers to the actual data
2482    //       double *ptr_0 = &((view_0.getData())[0]);
2483    //       double *ptr_2 = &((view_2.getData())[0]);
2484        // Get the pointers to the actual data        // Get the pointers to the actual data
2485        double *ptr_0 = &((view_0.getData())[0]);        double *ptr_0 = &(tmp_0->getDefaultValue(0));
2486        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &(tmp_2->getDefaultValue(0));
2487        // Compute a result for the default        // Compute a result for the default
2488        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2489        // Compute a result for each tag        // Compute a result for each tag
2490        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
2491        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
2492        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2493          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTag(i->first);
2494          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  /*        DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2495          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2496          double *ptr_0 = &view_0.getData(0);          double *ptr_0 = &view_0.getData(0);
2497          double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);*/
2498            double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
2499            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2500          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2501        }        }
2502    
# Line 2370  C_TensorBinaryOperation(Data const &arg_ Line 2515  C_TensorBinaryOperation(Data const &arg_
2515        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2516    
2517        // Get the views        // Get the views
2518        DataArrayView view_0 = tmp_0->getDefaultValue();  //       DataArrayView view_0 = tmp_0->getDefaultValue();
2519        DataArrayView view_1 = tmp_1->getDefaultValue();  //       DataArrayView view_1 = tmp_1->getDefaultValue();
2520        DataArrayView view_2 = tmp_2->getDefaultValue();  //       DataArrayView view_2 = tmp_2->getDefaultValue();
2521    //       // Get the pointers to the actual data
2522    //       double *ptr_0 = &((view_0.getData())[0]);
2523    //       double *ptr_1 = &((view_1.getData())[0]);
2524    //       double *ptr_2 = &((view_2.getData())[0]);
2525    
2526        // Get the pointers to the actual data        // Get the pointers to the actual data
2527        double *ptr_0 = &((view_0.getData())[0]);        double *ptr_0 = &(tmp_0->getDefaultValue(0));
2528        double *ptr_1 = &((view_1.getData())[0]);        double *ptr_1 = &(tmp_1->getDefaultValue(0));
2529        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &(tmp_2->getDefaultValue(0));
2530    
2531        // Compute a result for the default        // Compute a result for the default
2532        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2533        // Merge the tags        // Merge the tags
# Line 2384  C_TensorBinaryOperation(Data const &arg_ Line 2535  C_TensorBinaryOperation(Data const &arg_
2535        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();        const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
2536        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();        const DataTagged::DataMapType& lookup_1=tmp_1->getTagLookup();
2537        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2538          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue()); // use tmp_2 to get correct shape          tmp_2->addTag(i->first); // use tmp_2 to get correct shape
2539        }        }
2540        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2541          tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());          tmp_2->addTag(i->first);
2542        }        }
2543        // Compute a result for each tag        // Compute a result for each tag
2544        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();
2545        for (i=lookup_2.begin();i!=lookup_2.end();i++) {        for (i=lookup_2.begin();i!=lookup_2.end();i++) {
2546          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  //         DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2547          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);  //         DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
2548          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  //         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2549          double *ptr_0 = &view_0.getData(0);  //         double *ptr_0 = &view_0.getData(0);
2550          double *ptr_1 = &view_1.getData(0);  //         double *ptr_1 = &view_1.getData(0);
2551          double *ptr_2 = &view_2.getData(0);  //         double *ptr_2 = &view_2.getData(0);
2552    
2553            double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
2554            double *ptr_1 = &(tmp_1->getDataByTag(i->first,0));
2555            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2556          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2557        }        }
2558    
# Line 2416  C_TensorBinaryOperation(Data const &arg_ Line 2571  C_TensorBinaryOperation(Data const &arg_
2571        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2572        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2573          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
2574          double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);          double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2575          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2576            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);
2577            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2578            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2579            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &(res.getDataAtOffset(offset_2));
2580            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2581          }          }
2582        }        }
# Line 2443  C_TensorBinaryOperation(Data const &arg_ Line 2598  C_TensorBinaryOperation(Data const &arg_
2598          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2599            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2600            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2601            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2602            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2603            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &(res.getDataAtOffset(offset_2));
2604            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2605          }          }
2606        }        }
# Line 2466  C_TensorBinaryOperation(Data const &arg_ Line 2621  C_TensorBinaryOperation(Data const &arg_
2621        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)        #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2622        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {        for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2623          int offset_1 = tmp_1->getPointOffset(sampleNo_0,0);          int offset_1 = tmp_1->getPointOffset(sampleNo_0,0);
2624          double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);          double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2625          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2626            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2627            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2628            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2629            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &(res.getDataAtOffset(offset_2));
2630            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2631          }          }
2632        }        }
# Line 2494  C_TensorBinaryOperation(Data const &arg_ Line 2649  C_TensorBinaryOperation(Data const &arg_
2649            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2650            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_1 = tmp_1->getPointOffset(sampleNo_0,dataPointNo_0);
2651            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2652            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);            double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2653            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);            double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2654            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);            double *ptr_2 = &(res.getDataAtOffset(offset_2));
2655            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2656          }          }
2657        }        }
# Line 2523  C_TensorUnaryOperation(Data const &arg_0 Line 2678  C_TensorUnaryOperation(Data const &arg_0
2678    
2679    // Get rank and shape of inputs    // Get rank and shape of inputs
2680    int rank0 = arg_0_Z.getDataPointRank();    int rank0 = arg_0_Z.getDataPointRank();
2681    DataArrayView::ShapeType shape0 = arg_0_Z.getDataPointShape();    const DataTypes::ShapeType& shape0 = arg_0_Z.getDataPointShape();
2682    int size0 = arg_0_Z.getDataPointSize();    int size0 = arg_0_Z.getDataPointSize();
2683    
2684    // Declare output Data object    // Declare output Data object
# Line 2531  C_TensorUnaryOperation(Data const &arg_0 Line 2686  C_TensorUnaryOperation(Data const &arg_0
2686    
2687    if (arg_0_Z.isConstant()) {    if (arg_0_Z.isConstant()) {
2688      res = Data(0.0, shape0, arg_0_Z.getFunctionSpace());      // DataConstant output      res = Data(0.0, shape0, arg_0_Z.getFunctionSpace());      // DataConstant output
2689      double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);  //     double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);
2690      double *ptr_2 = &((res.getPointDataView().getData())[0]);  //     double *ptr_2 = &((res.getPointDataView().getData())[0]);
2691        double *ptr_0 = &(arg_0_Z.getDataAtOffset(0));
2692        double *ptr_2 = &(res.getDataAtOffset(0));
2693      tensor_unary_operation(size0, ptr_0, ptr_2, operation);      tensor_unary_operation(size0, ptr_0, ptr_2, operation);
2694    }    }
2695    else if (arg_0_Z.isTagged()) {    else if (arg_0_Z.isTagged()) {
# Line 2545  C_TensorUnaryOperation(Data const &arg_0 Line 2702  C_TensorUnaryOperation(Data const &arg_0
2702      res.tag();      res.tag();
2703      DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());      DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2704    
2705      // Get the views  //     // Get the views
2706      DataArrayView view_0 = tmp_0->getDefaultValue();  //     DataArrayView view_0 = tmp_0->getDefaultValue();
2707      DataArrayView view_2 = tmp_2->getDefaultValue();  //     DataArrayView view_2 = tmp_2->getDefaultValue();
2708    //     // Get the pointers to the actual data
2709    //     double *ptr_0 = &((view_0.getData())[0]);
2710    //     double *ptr_2 = &((view_2.getData())[0]);
2711      // Get the pointers to the actual data      // Get the pointers to the actual data
2712      double *ptr_0 = &((view_0.getData())[0]);      double *ptr_0 = &(tmp_0->getDefaultValue(0));
2713      double *ptr_2 = &((view_2.getData())[0]);      double *ptr_2 = &(tmp_2->getDefaultValue(0));
2714      // Compute a result for the default      // Compute a result for the default
2715      tensor_unary_operation(size0, ptr_0, ptr_2, operation);      tensor_unary_operation(size0, ptr_0, ptr_2, operation);
2716      // Compute a result for each tag      // Compute a result for each tag
2717      const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();      const DataTagged::DataMapType& lookup_0=tmp_0->getTagLookup();
2718      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
2719      for (i=lookup_0.begin();i!=lookup_0.end();i++) {      for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2720        tmp_2->addTaggedValue(i->first,tmp_2->getDefaultValue());        tmp_2->addTag(i->first);
2721        DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  //       DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2722        DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  //       DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2723        double *ptr_0 = &view_0.getData(0);  //       double *ptr_0 = &view_0.getData(0);
2724        double *ptr_2 = &view_2.getData(0);  //       double *ptr_2 = &view_2.getData(0);
2725          double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
2726          double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2727        tensor_unary_operation(size0, ptr_0, ptr_2, operation);        tensor_unary_operation(size0, ptr_0, ptr_2, operation);
2728      }      }
2729    
# Line 2578  C_TensorUnaryOperation(Data const &arg_0 Line 2740  C_TensorUnaryOperation(Data const &arg_0
2740      #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)      #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2741      for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {      for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2742        for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {        for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2743    //         int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2744    //         int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2745    //         double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2746    //         double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2747          int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);          int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2748          int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);          int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2749          double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);          double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2750          double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);          double *ptr_2 = &(res.getDataAtOffset(offset_2));
2751          tensor_unary_operation(size0, ptr_0, ptr_2, operation);          tensor_unary_operation(size0, ptr_0, ptr_2, operation);
2752        }        }
2753      }      }

Legend:
Removed from v.1748  
changed lines
  Added in v.1796

  ViewVC Help
Powered by ViewVC 1.1.26