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

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

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

revision 1711 by jfenwick, Thu Aug 14 05:35:32 2008 UTC revision 1712 by jfenwick, Wed Aug 20 05:04:28 2008 UTC
# Line 220  class Data { Line 220  class Data {
220         const boost::python::tuple& shape=boost::python::make_tuple(),         const boost::python::tuple& shape=boost::python::make_tuple(),
221         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
222         bool expanded=false);         bool expanded=false);
223    
224    
225    
226      /**
227        \brief Create a Data using an existing DataAbstract. Warning: The new object assumes ownership of the pointer!
228        Once you have passed the pointer, do not delete it.
229      */
230      ESCRIPT_DLL_API
231      Data(DataAbstract* underlyingdata);
232    
233    
234    /**    /**
235       \brief       \brief
236       Destructor       Destructor
# Line 1306  class Data { Line 1317  class Data {
1317       \brief       \brief
1318       Return a pointer to the beginning of the datapoint at the specified offset.       Return a pointer to the beginning of the datapoint at the specified offset.
1319       TODO Eventually these should be inlined.       TODO Eventually these should be inlined.
1320       \param i - position in the underlying datastructure       \param i - position(offset) in the underlying datastructure
1321    */    */
1322    ESCRIPT_DLL_API    ESCRIPT_DLL_API
1323          DataTypes::ValueType::const_reference          DataTypes::ValueType::const_reference
# Line 1556  C_GeneralTensorProduct(Data& arg0, Line 1567  C_GeneralTensorProduct(Data& arg0,
1567                       int transpose=0);                       int transpose=0);
1568    
1569    
 /**  
   \brief  
   Compute a tensor product of two Data objects.  
 This is Joel's test version. Not to be used for any serious purpose.  
   
   \param arg0 - Input - Data object  
   \param arg1 - Input - Data object  
   \param axis_offset - Input - axis offset  
   \param transpose - Input - 0: transpose neither, 1: transpose arg0, 2: transpose arg1  
 */  
 ESCRIPT_DLL_API  
 Data  
 C_GeneralTensorProduct_J(Data& arg0,  
                      Data& arg1,  
                      int axis_offset=0,  
                      int transpose=0);  
   
   
   
1570    
1571  /**  /**
1572    \brief    \brief
# Line 1703  Data::dp_algorithm(BinaryFunction operat Line 1695  Data::dp_algorithm(BinaryFunction operat
1695      return result;      return result;
1696    } else if (isTagged()) {    } else if (isTagged()) {
1697      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
     DataTypes::ShapeType viewShape;  
     DataTypes::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());  
1698      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1699      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");  
1700    //     DataTypes::ShapeType viewShape;
1701    //     DataTypes::ValueType viewData(1);
1702    //     viewData[0]=0;
1703    //     DataArrayView defaultValue(viewData,viewShape);
1704    //     DataTagged::TagListType keys;
1705    //     DataTagged::ValueListType values;
1706    //     DataTagged::DataMapType::const_iterator i;
1707    //     for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) {
1708    //       keys.push_back(i->first);
1709    //       values.push_back(defaultValue);
1710    //     }
1711    //     Data result(keys,values,defaultValue,getFunctionSpace());
1712    //     DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1713    //     EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1714    
1715    
1716    
1717    
1718        DataTypes::ValueType defval(1);
1719        defval[0]=0;
1720        DataTagged* resultT=new DataTagged(getFunctionSpace(), DataTypes::scalarShape, defval, *dataT);
1721      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1722      return result;      return Data(resultT);   // note: the Data object now owns the resultT pointer
1723    
1724    } else if (isConstant()) {    } else if (isConstant()) {
1725      Data result(0,DataTypes::ShapeType(),getFunctionSpace(),isExpanded());      Data result(0,DataTypes::ShapeType(),getFunctionSpace(),isExpanded());
1726      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
# Line 1780  C_TensorBinaryOperation(Data const &arg_ Line 1781  C_TensorBinaryOperation(Data const &arg_
1781    
1782      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {      if (arg_0_Z.isConstant()   && arg_1_Z.isConstant()) {
1783        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());      // DataConstant output        res = Data(0.0, shape0, arg_1_Z.getFunctionSpace());      // DataConstant output
1784        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);  /*      double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);
1785        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[0]);        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[0]);
1786        double *ptr_2 = &((res.getPointDataView().getData())[0]);        double *ptr_2 = &((res.getPointDataView().getData())[0]);*/
1787          double *ptr_0 = &(arg_0_Z.getDataAtOffset(0));
1788          double *ptr_1 = &(arg_1_Z.getDataAtOffset(0));
1789          double *ptr_2 = &(res.getDataAtOffset(0));
1790    
1791        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1792      }      }
1793      else if (arg_0_Z.isConstant()   && arg_1_Z.isTagged()) {      else if (arg_0_Z.isConstant()   && arg_1_Z.isTagged()) {
# Line 1800  C_TensorBinaryOperation(Data const &arg_ Line 1805  C_TensorBinaryOperation(Data const &arg_
1805    
1806        // Prepare offset into DataConstant        // Prepare offset into DataConstant
1807        int offset_0 = tmp_0->getPointOffset(0,0);        int offset_0 = tmp_0->getPointOffset(0,0);
1808        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);        double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
1809        // Get the views        // Get the views
1810        DataArrayView view_1 = tmp_1->getDefaultValue();  //       DataArrayView view_1 = tmp_1->getDefaultValue();
1811        DataArrayView view_2 = tmp_2->getDefaultValue();  //       DataArrayView view_2 = tmp_2->getDefaultValue();
1812    //       // Get the pointers to the actual data
1813    //       double *ptr_1 = &((view_1.getData())[0]);
1814    //       double *ptr_2 = &((view_2.getData())[0]);
1815    
1816        // Get the pointers to the actual data        // Get the pointers to the actual data
1817        double *ptr_1 = &((view_1.getData())[0]);        double *ptr_1 = &(tmp_1->getDefaultValue(0));
1818        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &(tmp_2->getDefaultValue(0));
1819    
1820        // Compute a result for the default        // Compute a result for the default
1821        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1822        // Compute a result for each tag        // Compute a result for each tag
# Line 1814  C_TensorBinaryOperation(Data const &arg_ Line 1824  C_TensorBinaryOperation(Data const &arg_
1824        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
1825        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
1826          tmp_2->addTag(i->first);          tmp_2->addTag(i->first);
1827          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);  /*        DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
1828          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
1829          double *ptr_1 = &view_1.getData(0);          double *ptr_1 = &view_1.getData(0);
1830          double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);*/
1831            double *ptr_1 = &(tmp_1->getDataByTag(i->first,0));
1832            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
1833    
1834          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1835        }        }
1836    
# Line 1838  C_TensorBinaryOperation(Data const &arg_ Line 1851  C_TensorBinaryOperation(Data const &arg_
1851          for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {          for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {
1852            int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_1 = tmp_1->getPointOffset(sampleNo_1,dataPointNo_1);
1853            int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);            int offset_2 = tmp_2->getPointOffset(sampleNo_1,dataPointNo_1);
1854            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);  //           double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
1855            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);  //           double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
1856            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);  //           double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
1857    
1858              double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
1859              double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
1860              double *ptr_2 = &(res.getDataAtOffset(offset_2));
1861            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1862          }          }
1863        }        }
# Line 1861  C_TensorBinaryOperation(Data const &arg_ Line 1878  C_TensorBinaryOperation(Data const &arg_
1878    
1879        // Prepare offset into DataConstant        // Prepare offset into DataConstant
1880        int offset_1 = tmp_1->getPointOffset(0,0);        int offset_1 = tmp_1->getPointOffset(0,0);
1881        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);  //       double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
1882          double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
1883        // Get the views        // Get the views
1884        DataArrayView view_0 = tmp_0->getDefaultValue();  //       DataArrayView view_0 = tmp_0->getDefaultValue();
1885        DataArrayView view_2 = tmp_2->getDefaultValue();  //       DataArrayView view_2 = tmp_2->getDefaultValue();
1886    //       // Get the pointers to the actual data
1887    //       double *ptr_0 = &((view_0.getData())[0]);
1888    //       double *ptr_2 = &((view_2.getData())[0]);
1889        // Get the pointers to the actual data        // Get the pointers to the actual data
1890        double *ptr_0 = &((view_0.getData())[0]);        double *ptr_0 = &(tmp_0->getDefaultValue(0));
1891        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &(tmp_2->getDefaultValue(0));
1892        // Compute a result for the default        // Compute a result for the default
1893        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1894        // Compute a result for each tag        // Compute a result for each tag
# Line 1875  C_TensorBinaryOperation(Data const &arg_ Line 1896  C_TensorBinaryOperation(Data const &arg_
1896        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
1897        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
1898          tmp_2->addTag(i->first);          tmp_2->addTag(i->first);
1899          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  //         DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
1900          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  //         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
1901          double *ptr_0 = &view_0.getData(0);  //         double *ptr_0 = &view_0.getData(0);
1902          double *ptr_2 = &view_2.getData(0);  //         double *ptr_2 = &view_2.getData(0);
1903            double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
1904            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
1905          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1906        }        }
1907    
# Line 1896  C_TensorBinaryOperation(Data const &arg_ Line 1919  C_TensorBinaryOperation(Data const &arg_
1919        res.tag();        // DataTagged output        res.tag();        // DataTagged output
1920        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
1921    
1922        // Get the views  //       // Get the views
1923        DataArrayView view_0 = tmp_0->getDefaultValue();  //       DataArrayView view_0 = tmp_0->getDefaultValue();
1924        DataArrayView view_1 = tmp_1->getDefaultValue();  //       DataArrayView view_1 = tmp_1->getDefaultValue();
1925        DataArrayView view_2 = tmp_2->getDefaultValue();  //       DataArrayView view_2 = tmp_2->getDefaultValue();
1926    //       // Get the pointers to the actual data
1927    //       double *ptr_0 = &((view_0.getData())[0]);
1928    //       double *ptr_1 = &((view_1.getData())[0]);
1929    //       double *ptr_2 = &((view_2.getData())[0]);
1930    
1931        // Get the pointers to the actual data        // Get the pointers to the actual data
1932        double *ptr_0 = &((view_0.getData())[0]);        double *ptr_0 = &(tmp_0->getDefaultValue(0));
1933        double *ptr_1 = &((view_1.getData())[0]);        double *ptr_1 = &(tmp_1->getDefaultValue(0));
1934        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &(tmp_2->getDefaultValue(0));
1935    
1936        // Compute a result for the default        // Compute a result for the default
1937        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1938        // Merge the tags        // Merge the tags
# Line 1919  C_TensorBinaryOperation(Data const &arg_ Line 1948  C_TensorBinaryOperation(Data const &arg_
1948        // Compute a result for each tag        // Compute a result for each tag
1949        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();
1950        for (i=lookup_2.begin();i!=lookup_2.end();i++) {        for (i=lookup_2.begin();i!=lookup_2.end();i++) {
1951          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  
1952          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);  //         DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
1953          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  //         DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
1954          double *ptr_0 = &view_0.getData(0);  //         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
1955          double *ptr_1 = &view_1.getData(0);  //         double *ptr_0 = &view_0.getData(0);
1956          double *ptr_2 = &view_2.getData(0);  //         double *ptr_1 = &view_1.getData(0);
1957    //         double *ptr_2 = &view_2.getData(0);
1958    
1959            double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
1960            double *ptr_1 = &(tmp_1->getDataByTag(i->first,0));
1961            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
1962    
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    
# Line 1947  C_TensorBinaryOperation(Data const &arg_ Line 1982  C_TensorBinaryOperation(Data const &arg_
1982          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_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_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);  
1986            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);  //           double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
1987    //           double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
1988              double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
1989              double *ptr_2 = &(res.getDataAtOffset(offset_2));
1990    
1991    
1992            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
1993          }          }
1994        }        }
# Line 1970  C_TensorBinaryOperation(Data const &arg_ Line 2010  C_TensorBinaryOperation(Data const &arg_
2010          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {          for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2011            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2012            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);            int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2013            double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);  
2014            double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);  //           double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2015            double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);  //           double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2016    //           double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2017    
2018              double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2019              double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2020              double *ptr_2 = &(res.getDataAtOffset(offset_2));
2021    
2022    
2023            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);            tensor_binary_operation(size0, ptr_0, ptr_1, ptr_2, operation);
2024          }          }
2025        }        }
# Line 2058  C_TensorBinaryOperation(Data const &arg_ Line 2105  C_TensorBinaryOperation(Data const &arg_
2105        int offset_0 = tmp_0->getPointOffset(0,0);        int offset_0 = tmp_0->getPointOffset(0,0);
2106        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2107        // Get the views        // Get the views
2108        DataArrayView view_1 = tmp_1->getDefaultValue();  //       DataArrayView view_1 = tmp_1->getDefaultValue();
2109        DataArrayView view_2 = tmp_2->getDefaultValue();  //       DataArrayView view_2 = tmp_2->getDefaultValue();
2110        // Get the pointers to the actual data  //       // Get the pointers to the actual data
2111        double *ptr_1 = &((view_1.getData())[0]);  //       double *ptr_1 = &((view_1.getData())[0]);
2112        double *ptr_2 = &((view_2.getData())[0]);  //       double *ptr_2 = &((view_2.getData())[0]);
2113           double *ptr_1 = &(tmp_1->getDefaultValue(0));
2114           double *ptr_2 = &(tmp_2->getDefaultValue(0));
2115    
2116        // Compute a result for the default        // Compute a result for the default
2117        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2118        // Compute a result for each tag        // Compute a result for each tag
# Line 2070  C_TensorBinaryOperation(Data const &arg_ Line 2120  C_TensorBinaryOperation(Data const &arg_
2120        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
2121        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2122          tmp_2->addTag(i->first);          tmp_2->addTag(i->first);
2123          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);  //         DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
2124          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  //         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2125          double *ptr_1 = &view_1.getData(0);  //         double *ptr_1 = &view_1.getData(0);
2126          double *ptr_2 = &view_2.getData(0);  //         double *ptr_2 = &view_2.getData(0);
2127            double *ptr_1 = &(tmp_1->getDataByTag(i->first,0));
2128            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2129          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2130        }        }
2131    
# Line 2118  C_TensorBinaryOperation(Data const &arg_ Line 2170  C_TensorBinaryOperation(Data const &arg_
2170    
2171        // Prepare offset into DataConstant        // Prepare offset into DataConstant
2172        int offset_1 = tmp_1->getPointOffset(0,0);        int offset_1 = tmp_1->getPointOffset(0,0);
2173        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);  //       double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2174          double *ptr_1 = &(arg_1_Z.getDataAtOffset(offset_1));
2175        // Get the views        // Get the views
2176        DataArrayView view_0 = tmp_0->getDefaultValue();  /*      DataArrayView view_0 = tmp_0->getDefaultValue();
2177        DataArrayView view_2 = tmp_2->getDefaultValue();        DataArrayView view_2 = tmp_2->getDefaultValue();
2178        // Get the pointers to the actual data        // Get the pointers to the actual data
2179        double *ptr_0 = &((view_0.getData())[0]);        double *ptr_0 = &((view_0.getData())[0]);
2180        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &((view_2.getData())[0]);*/
2181    
2182          // Get the pointers to the actual data
2183          double *ptr_0 = &(tmp_0->getDefaultValue(0));
2184          double *ptr_2 = &(tmp_2->getDefaultValue(0));
2185    
2186    
2187        // Compute a result for the default        // Compute a result for the default
2188        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2189        // Compute a result for each tag        // Compute a result for each tag
# Line 2132  C_TensorBinaryOperation(Data const &arg_ Line 2191  C_TensorBinaryOperation(Data const &arg_
2191        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
2192        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2193          tmp_2->addTag(i->first);          tmp_2->addTag(i->first);
2194          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  /*        DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2195          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2196          double *ptr_0 = &view_0.getData(0);          double *ptr_0 = &view_0.getData(0);
2197          double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);*/
2198            double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
2199            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2200    
2201          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2202        }        }
2203    
# Line 2154  C_TensorBinaryOperation(Data const &arg_ Line 2216  C_TensorBinaryOperation(Data const &arg_
2216        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2217    
2218        // Get the views        // Get the views
2219        DataArrayView view_0 = tmp_0->getDefaultValue();  /*      DataArrayView view_0 = tmp_0->getDefaultValue();
2220        DataArrayView view_1 = tmp_1->getDefaultValue();        DataArrayView view_1 = tmp_1->getDefaultValue();
2221        DataArrayView view_2 = tmp_2->getDefaultValue();        DataArrayView view_2 = tmp_2->getDefaultValue();
2222        // Get the pointers to the actual data        // Get the pointers to the actual data
2223        double *ptr_0 = &((view_0.getData())[0]);        double *ptr_0 = &((view_0.getData())[0]);
2224        double *ptr_1 = &((view_1.getData())[0]);        double *ptr_1 = &((view_1.getData())[0]);
2225        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &((view_2.getData())[0]);*/
2226    
2227          // Get the pointers to the actual data
2228          double *ptr_0 = &(tmp_0->getDefaultValue(0));
2229          double *ptr_1 = &(tmp_1->getDefaultValue(0));
2230          double *ptr_2 = &(tmp_2->getDefaultValue(0));
2231    
2232    
2233        // Compute a result for the default        // Compute a result for the default
2234        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);        tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2235        // Merge the tags        // Merge the tags
# Line 2176  C_TensorBinaryOperation(Data const &arg_ Line 2245  C_TensorBinaryOperation(Data const &arg_
2245        // Compute a result for each tag        // Compute a result for each tag
2246        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();
2247        for (i=lookup_2.begin();i!=lookup_2.end();i++) {        for (i=lookup_2.begin();i!=lookup_2.end();i++) {
2248          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  
2249    /*        DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2250          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
2251          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2252          double *ptr_0 = &view_0.getData(0);          double *ptr_0 = &view_0.getData(0);
2253          double *ptr_1 = &view_1.getData(0);          double *ptr_1 = &view_1.getData(0);
2254          double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);*/
2255    
2256            double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
2257            double *ptr_1 = &(tmp_1->getDataByTag(i->first,0));
2258            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2259    
2260          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);          tensor_binary_operation(size1, ptr_0[0], ptr_1, ptr_2, operation);
2261        }        }
2262    
# Line 2316  C_TensorBinaryOperation(Data const &arg_ Line 2391  C_TensorBinaryOperation(Data const &arg_
2391        int offset_0 = tmp_0->getPointOffset(0,0);        int offset_0 = tmp_0->getPointOffset(0,0);
2392        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);        double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2393        // Get the views        // Get the views
2394        DataArrayView view_1 = tmp_1->getDefaultValue();  /*      DataArrayView view_1 = tmp_1->getDefaultValue();
2395        DataArrayView view_2 = tmp_2->getDefaultValue();        DataArrayView view_2 = tmp_2->getDefaultValue();
2396        // Get the pointers to the actual data        // Get the pointers to the actual data
2397        double *ptr_1 = &((view_1.getData())[0]);        double *ptr_1 = &((view_1.getData())[0]);
2398        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &((view_2.getData())[0]);*/
2399          //Get the pointers to the actual data
2400          double *ptr_1 = &(tmp_1->getDefaultValue(0));
2401          double *ptr_2 = &(tmp_2->getDefaultValue(0));
2402    
2403        // Compute a result for the default        // Compute a result for the default
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        // Compute a result for each tag        // Compute a result for each tag
# Line 2328  C_TensorBinaryOperation(Data const &arg_ Line 2407  C_TensorBinaryOperation(Data const &arg_
2407        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
2408        for (i=lookup_1.begin();i!=lookup_1.end();i++) {        for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2409          tmp_2->addTag(i->first);          tmp_2->addTag(i->first);
2410          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);  //         DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
2411          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  //         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2412          double *ptr_1 = &view_1.getData(0);  //         double *ptr_1 = &view_1.getData(0);
2413          double *ptr_2 = &view_2.getData(0);  //         double *ptr_2 = &view_2.getData(0);
2414            double *ptr_1 = &(tmp_1->getDataByTag(i->first,0));
2415            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2416    
2417    
2418          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2419        }        }
2420    
# Line 2377  C_TensorBinaryOperation(Data const &arg_ Line 2460  C_TensorBinaryOperation(Data const &arg_
2460        int offset_1 = tmp_1->getPointOffset(0,0);        int offset_1 = tmp_1->getPointOffset(0,0);
2461        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);        double *ptr_1 = &((arg_1_Z.getPointDataView().getData())[offset_1]);
2462        // Get the views        // Get the views
2463        DataArrayView view_0 = tmp_0->getDefaultValue();  //       DataArrayView view_0 = tmp_0->getDefaultValue();
2464        DataArrayView view_2 = tmp_2->getDefaultValue();  //       DataArrayView view_2 = tmp_2->getDefaultValue();
2465    //       // Get the pointers to the actual data
2466    //       double *ptr_0 = &((view_0.getData())[0]);
2467    //       double *ptr_2 = &((view_2.getData())[0]);
2468        // Get the pointers to the actual data        // Get the pointers to the actual data
2469        double *ptr_0 = &((view_0.getData())[0]);        double *ptr_0 = &(tmp_0->getDefaultValue(0));
2470        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &(tmp_2->getDefaultValue(0));
2471        // Compute a result for the default        // Compute a result for the default
2472        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2473        // Compute a result for each tag        // Compute a result for each tag
# Line 2389  C_TensorBinaryOperation(Data const &arg_ Line 2475  C_TensorBinaryOperation(Data const &arg_
2475        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
2476        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2477          tmp_2->addTag(i->first);          tmp_2->addTag(i->first);
2478          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  /*        DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2479          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2480          double *ptr_0 = &view_0.getData(0);          double *ptr_0 = &view_0.getData(0);
2481          double *ptr_2 = &view_2.getData(0);          double *ptr_2 = &view_2.getData(0);*/
2482            double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
2483            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2484          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2485        }        }
2486    
# Line 2411  C_TensorBinaryOperation(Data const &arg_ Line 2499  C_TensorBinaryOperation(Data const &arg_
2499        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());        DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2500    
2501        // Get the views        // Get the views
2502        DataArrayView view_0 = tmp_0->getDefaultValue();  //       DataArrayView view_0 = tmp_0->getDefaultValue();
2503        DataArrayView view_1 = tmp_1->getDefaultValue();  //       DataArrayView view_1 = tmp_1->getDefaultValue();
2504        DataArrayView view_2 = tmp_2->getDefaultValue();  //       DataArrayView view_2 = tmp_2->getDefaultValue();
2505    //       // Get the pointers to the actual data
2506    //       double *ptr_0 = &((view_0.getData())[0]);
2507    //       double *ptr_1 = &((view_1.getData())[0]);
2508    //       double *ptr_2 = &((view_2.getData())[0]);
2509    
2510        // Get the pointers to the actual data        // Get the pointers to the actual data
2511        double *ptr_0 = &((view_0.getData())[0]);        double *ptr_0 = &(tmp_0->getDefaultValue(0));
2512        double *ptr_1 = &((view_1.getData())[0]);        double *ptr_1 = &(tmp_1->getDefaultValue(0));
2513        double *ptr_2 = &((view_2.getData())[0]);        double *ptr_2 = &(tmp_2->getDefaultValue(0));
2514    
2515        // Compute a result for the default        // Compute a result for the default
2516        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);        tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2517        // Merge the tags        // Merge the tags
# Line 2433  C_TensorBinaryOperation(Data const &arg_ Line 2527  C_TensorBinaryOperation(Data const &arg_
2527        // Compute a result for each tag        // Compute a result for each tag
2528        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();
2529        for (i=lookup_2.begin();i!=lookup_2.end();i++) {        for (i=lookup_2.begin();i!=lookup_2.end();i++) {
2530          DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  //         DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2531          DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);  //         DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);
2532          DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  //         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2533          double *ptr_0 = &view_0.getData(0);  //         double *ptr_0 = &view_0.getData(0);
2534          double *ptr_1 = &view_1.getData(0);  //         double *ptr_1 = &view_1.getData(0);
2535          double *ptr_2 = &view_2.getData(0);  //         double *ptr_2 = &view_2.getData(0);
2536    
2537            double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
2538            double *ptr_1 = &(tmp_1->getDataByTag(i->first,0));
2539            double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2540          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
2541        }        }
2542    
# Line 2564  C_TensorUnaryOperation(Data const &arg_0 Line 2662  C_TensorUnaryOperation(Data const &arg_0
2662    
2663    // Get rank and shape of inputs    // Get rank and shape of inputs
2664    int rank0 = arg_0_Z.getDataPointRank();    int rank0 = arg_0_Z.getDataPointRank();
2665    DataTypes::ShapeType shape0 = arg_0_Z.getDataPointShape();    const DataTypes::ShapeType& shape0 = arg_0_Z.getDataPointShape();
2666    int size0 = arg_0_Z.getDataPointSize();    int size0 = arg_0_Z.getDataPointSize();
2667    
2668    // Declare output Data object    // Declare output Data object
# Line 2572  C_TensorUnaryOperation(Data const &arg_0 Line 2670  C_TensorUnaryOperation(Data const &arg_0
2670    
2671    if (arg_0_Z.isConstant()) {    if (arg_0_Z.isConstant()) {
2672      res = Data(0.0, shape0, arg_0_Z.getFunctionSpace());      // DataConstant output      res = Data(0.0, shape0, arg_0_Z.getFunctionSpace());      // DataConstant output
2673      double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);  //     double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);
2674      double *ptr_2 = &((res.getPointDataView().getData())[0]);  //     double *ptr_2 = &((res.getPointDataView().getData())[0]);
2675        double *ptr_0 = &(arg_0_Z.getDataAtOffset(0));
2676        double *ptr_2 = &(res.getDataAtOffset(0));
2677      tensor_unary_operation(size0, ptr_0, ptr_2, operation);      tensor_unary_operation(size0, ptr_0, ptr_2, operation);
2678    }    }
2679    else if (arg_0_Z.isTagged()) {    else if (arg_0_Z.isTagged()) {
# Line 2586  C_TensorUnaryOperation(Data const &arg_0 Line 2686  C_TensorUnaryOperation(Data const &arg_0
2686      res.tag();      res.tag();
2687      DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());      DataTagged* tmp_2=dynamic_cast<DataTagged*>(res.borrowData());
2688    
2689      // Get the views  //     // Get the views
2690      DataArrayView view_0 = tmp_0->getDefaultValue();  //     DataArrayView view_0 = tmp_0->getDefaultValue();
2691      DataArrayView view_2 = tmp_2->getDefaultValue();  //     DataArrayView view_2 = tmp_2->getDefaultValue();
2692    //     // Get the pointers to the actual data
2693    //     double *ptr_0 = &((view_0.getData())[0]);
2694    //     double *ptr_2 = &((view_2.getData())[0]);
2695      // Get the pointers to the actual data      // Get the pointers to the actual data
2696      double *ptr_0 = &((view_0.getData())[0]);      double *ptr_0 = &(tmp_0->getDefaultValue(0));
2697      double *ptr_2 = &((view_2.getData())[0]);      double *ptr_2 = &(tmp_2->getDefaultValue(0));
2698      // Compute a result for the default      // Compute a result for the default
2699      tensor_unary_operation(size0, ptr_0, ptr_2, operation);      tensor_unary_operation(size0, ptr_0, ptr_2, operation);
2700      // Compute a result for each tag      // Compute a result for each tag
# Line 2599  C_TensorUnaryOperation(Data const &arg_0 Line 2702  C_TensorUnaryOperation(Data const &arg_0
2702      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
2703      for (i=lookup_0.begin();i!=lookup_0.end();i++) {      for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2704        tmp_2->addTag(i->first);        tmp_2->addTag(i->first);
2705        DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  //       DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);
2706        DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  //       DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);
2707        double *ptr_0 = &view_0.getData(0);  //       double *ptr_0 = &view_0.getData(0);
2708        double *ptr_2 = &view_2.getData(0);  //       double *ptr_2 = &view_2.getData(0);
2709          double *ptr_0 = &(tmp_0->getDataByTag(i->first,0));
2710          double *ptr_2 = &(tmp_2->getDataByTag(i->first,0));
2711        tensor_unary_operation(size0, ptr_0, ptr_2, operation);        tensor_unary_operation(size0, ptr_0, ptr_2, operation);
2712      }      }
2713    
# Line 2619  C_TensorUnaryOperation(Data const &arg_0 Line 2724  C_TensorUnaryOperation(Data const &arg_0
2724      #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)      #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2725      for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {      for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2726        for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {        for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2727    //         int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2728    //         int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2729    //         double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);
2730    //         double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);
2731          int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);          int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2732          int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);          int offset_2 = tmp_2->getPointOffset(sampleNo_0,dataPointNo_0);
2733          double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[offset_0]);          double *ptr_0 = &(arg_0_Z.getDataAtOffset(offset_0));
2734          double *ptr_2 = &((res.getPointDataView().getData())[offset_2]);          double *ptr_2 = &(res.getDataAtOffset(offset_2));
2735          tensor_unary_operation(size0, ptr_0, ptr_2, operation);          tensor_unary_operation(size0, ptr_0, ptr_2, operation);
2736        }        }
2737      }      }

Legend:
Removed from v.1711  
changed lines
  Added in v.1712

  ViewVC Help
Powered by ViewVC 1.1.26