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

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

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

revision 2458 by jfenwick, Wed Jun 3 06:18:21 2009 UTC revision 2459 by jfenwick, Thu Jun 4 06:17:54 2009 UTC
# Line 117  class Data { Line 117  class Data {
117    
118    /**    /**
119       \brief       \brief
120       Constructor which creates a Data from a DataArrayView shape.       Constructor which creates a Data with points having the specified shape.
121    
122       \param value - Input - Single value applied to all Data.       \param value - Input - Single value applied to all Data.
123       \param dataPointShape - Input - The shape of each data point.       \param dataPointShape - Input - The shape of each data point.
# Line 559  contains datapoints. Line 559  contains datapoints.
559    void    void
560    dump(const std::string fileName) const;    dump(const std::string fileName) const;
561    
562  //  /**   /**
563  //     \brief    \brief returns the values of the object as a list of tuples (one for each datapoint).
564  //     Return the sample data for the given sample no. This is not the  
565  //     preferred interface but is provided for use by C code.    \param scalarastuple If true, scalar data will produce single valued tuples [(1,) (2,) ...]
566  //     The buffer parameter is only required for LazyData.  If false, the result is a list of scalars [1, 2, ...]
567  //     \param sampleNo - Input - the given sample no.   */
568  //     \param buffer - Vector to compute (and store) sample data in.    ESCRIPT_DLL_API
569  //     \return pointer to the sample data.    const boost::python::object
570  //*/    toListOfTuples(bool scalarastuple=false);
 //   ESCRIPT_DLL_API  
 //   inline  
 //   const DataAbstract::ValueType::value_type*  
 //   getSampleDataRO(DataAbstract::ValueType::size_type sampleNo, DataTypes::ValueType* buffer=0);  
571    
572    
573   /**   /**
# Line 618  contains datapoints. Line 614  contains datapoints.
614    
615    /**    /**
616       \brief       \brief
617       Return a view into the data for the data point specified.       Return a reference into the DataVector which points to the specified data point.
      NOTE: Construction of the DataArrayView is a relatively expensive  
      operation.  
618       \param sampleNo - Input -       \param sampleNo - Input -
619       \param dataPointNo - Input -       \param dataPointNo - Input -
620    */    */
# Line 628  contains datapoints. Line 622  contains datapoints.
622    DataTypes::ValueType::const_reference    DataTypes::ValueType::const_reference
623    getDataPointRO(int sampleNo, int dataPointNo);    getDataPointRO(int sampleNo, int dataPointNo);
624    
625      /**
626         \brief
627         Return a reference into the DataVector which points to the specified data point.
628         \param sampleNo - Input -
629         \param dataPointNo - Input -
630      */
631    ESCRIPT_DLL_API    ESCRIPT_DLL_API
632    DataTypes::ValueType::reference    DataTypes::ValueType::reference
633    getDataPointRW(int sampleNo, int dataPointNo);    getDataPointRW(int sampleNo, int dataPointNo);
# Line 2533  C_TensorBinaryOperation(Data const &arg_ Line 2532  C_TensorBinaryOperation(Data const &arg_
2532        // Compute a result for each tag        // Compute a result for each tag
2533        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();
2534        for (i=lookup_2.begin();i!=lookup_2.end();i++) {        for (i=lookup_2.begin();i!=lookup_2.end();i++) {
   
 /*        DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  
         DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);  
         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  
         double *ptr_0 = &view_0.getData(0);  
         double *ptr_1 = &view_1.getData(0);  
         double *ptr_2 = &view_2.getData(0);*/  
   
2535          const double *ptr_0 = &(tmp_0->getDataByTagRO(i->first,0));          const double *ptr_0 = &(tmp_0->getDataByTagRO(i->first,0));
2536          const double *ptr_1 = &(tmp_1->getDataByTagRO(i->first,0));          const double *ptr_1 = &(tmp_1->getDataByTagRO(i->first,0));
2537          double *ptr_2 = &(tmp_2->getDataByTagRW(i->first,0));          double *ptr_2 = &(tmp_2->getDataByTagRW(i->first,0));
# Line 2748  C_TensorBinaryOperation(Data const &arg_ Line 2739  C_TensorBinaryOperation(Data const &arg_
2739        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
2740        for (i=lookup_0.begin();i!=lookup_0.end();i++) {        for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2741          tmp_2->addTag(i->first);          tmp_2->addTag(i->first);
 /*        DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  
         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  
         double *ptr_0 = &view_0.getData(0);  
         double *ptr_2 = &view_2.getData(0);*/  
2742          const double *ptr_0 = &(tmp_0->getDataByTagRO(i->first,0));          const double *ptr_0 = &(tmp_0->getDataByTagRO(i->first,0));
2743          double *ptr_2 = &(tmp_2->getDataByTagRW(i->first,0));          double *ptr_2 = &(tmp_2->getDataByTagRW(i->first,0));
2744          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);          tensor_binary_operation(size0, ptr_0, ptr_1[0], ptr_2, operation);
# Line 2791  C_TensorBinaryOperation(Data const &arg_ Line 2778  C_TensorBinaryOperation(Data const &arg_
2778        // Compute a result for each tag        // Compute a result for each tag
2779        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();        const DataTagged::DataMapType& lookup_2=tmp_2->getTagLookup();
2780        for (i=lookup_2.begin();i!=lookup_2.end();i++) {        for (i=lookup_2.begin();i!=lookup_2.end();i++) {
 //         DataArrayView view_0 = tmp_0->getDataPointByTag(i->first);  
 //         DataArrayView view_1 = tmp_1->getDataPointByTag(i->first);  
 //         DataArrayView view_2 = tmp_2->getDataPointByTag(i->first);  
 //         double *ptr_0 = &view_0.getData(0);  
 //         double *ptr_1 = &view_1.getData(0);  
 //         double *ptr_2 = &view_2.getData(0);  
   
2781          const double *ptr_0 = &(tmp_0->getDataByTagRO(i->first,0));          const double *ptr_0 = &(tmp_0->getDataByTagRO(i->first,0));
2782          const double *ptr_1 = &(tmp_1->getDataByTagRO(i->first,0));          const double *ptr_1 = &(tmp_1->getDataByTagRO(i->first,0));
2783          double *ptr_2 = &(tmp_2->getDataByTagRW(i->first,0));          double *ptr_2 = &(tmp_2->getDataByTagRW(i->first,0));
# Line 2936  C_TensorUnaryOperation(Data const &arg_0 Line 2916  C_TensorUnaryOperation(Data const &arg_0
2916    Data arg_0_Z = Data(arg_0);    Data arg_0_Z = Data(arg_0);
2917    
2918    // Get rank and shape of inputs    // Get rank and shape of inputs
 //  int rank0 = arg_0_Z.getDataPointRank();  
2919    const DataTypes::ShapeType& shape0 = arg_0_Z.getDataPointShape();    const DataTypes::ShapeType& shape0 = arg_0_Z.getDataPointShape();
2920    int size0 = arg_0_Z.getDataPointSize();    int size0 = arg_0_Z.getDataPointSize();
2921    
# Line 2945  C_TensorUnaryOperation(Data const &arg_0 Line 2924  C_TensorUnaryOperation(Data const &arg_0
2924    
2925    if (arg_0_Z.isConstant()) {    if (arg_0_Z.isConstant()) {
2926      res = Data(0.0, shape0, arg_0_Z.getFunctionSpace());      // DataConstant output      res = Data(0.0, shape0, arg_0_Z.getFunctionSpace());      // DataConstant output
 //     double *ptr_0 = &((arg_0_Z.getPointDataView().getData())[0]);  
 //     double *ptr_2 = &((res.getPointDataView().getData())[0]);  
2927      const double *ptr_0 = &(arg_0_Z.getDataAtOffsetRO(0));      const double *ptr_0 = &(arg_0_Z.getDataAtOffsetRO(0));
2928      double *ptr_2 = &(res.getDataAtOffsetRW(0));      double *ptr_2 = &(res.getDataAtOffsetRW(0));
2929      tensor_unary_operation(size0, ptr_0, ptr_2, operation);      tensor_unary_operation(size0, ptr_0, ptr_2, operation);

Legend:
Removed from v.2458  
changed lines
  Added in v.2459

  ViewVC Help
Powered by ViewVC 1.1.26