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

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

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

revision 126 by jgs, Fri Jul 22 03:53:08 2005 UTC revision 149 by jgs, Thu Sep 1 03:31:39 2005 UTC
# Line 44  extern "C" { Line 44  extern "C" {
44  namespace escript {  namespace escript {
45    
46  //  //
47  // Forward declaration for various implimentations of Data.  // Forward declaration for various implementations of Data.
48  class DataEmpty;  class DataEmpty;
49  class DataConstant;  class DataConstant;
50  class DataTagged;  class DataTagged;
# Line 226  class Data { Line 226  class Data {
226    convertToNumArray();    convertToNumArray();
227    
228    /**    /**
      \brief fills the expanded Data object from values of a  python numarray object.  
   
   */  
   void  
   fillFromNumArray(const boost::python::numeric::array);  
   /**  
229       \brief       \brief
230       Return the values of all data-points for the given sample as a single python numarray object.       Return the values of all data-points for the given sample as a single python numarray object.
231    */    */
# Line 248  class Data { Line 242  class Data {
242    
243    /**    /**
244       \brief       \brief
245         Fills the expanded Data object from values of a python numarray object.
246      */
247      void
248      fillFromNumArray(const boost::python::numeric::array);
249    
250      /**
251         \brief
252         Return the tag number associated with the given data-point.
253    
254         The data-point number here corresponds to the data-point number in the
255         numarray returned by convertToNumArray.
256      */
257      int
258      getTagNumber(int dpno);
259    
260      /**
261         \brief
262       Return the C wrapper for the Data object.       Return the C wrapper for the Data object.
263    */    */
264    escriptDataC    escriptDataC
# Line 684  class Data { Line 695  class Data {
695    const boost::python::tuple    const boost::python::tuple
696    mindp() const;    mindp() const;
697    
698      void
699      calc_mindp(int& SampleNo,
700                 int& DataPointNo) const;
701    
702    /**    /**
703       \brief       \brief
704       Return the length of each data point of this Data object.       Return the length of each data point of this Data object.
# Line 983  class Data { Line 998  class Data {
998       Perform the specified reduction algorithm on every element of every data point in       Perform the specified reduction algorithm on every element of every data point in
999       this Data object according to the given function and return the single value result.       this Data object according to the given function and return the single value result.
1000    */    */
1001    template <class UnaryFunction>    template <class BinaryFunction>
1002    inline    inline
1003    double    double
1004    algorithm(UnaryFunction operation) const;    algorithm(BinaryFunction operation,
1005                double initial_value) const;
1006    
1007    /**    /**
1008       \brief       \brief
# Line 995  class Data { Line 1011  class Data {
1011       one value - the result of the reduction operation on the corresponding data-point in       one value - the result of the reduction operation on the corresponding data-point in
1012       this Data object       this Data object
1013    */    */
1014    template <class UnaryFunction>    template <class BinaryFunction>
1015    inline    inline
1016    Data    Data
1017    dp_algorithm(UnaryFunction operation) const;    dp_algorithm(BinaryFunction operation,
1018                   double initial_value) const;
1019    
1020    /**    /**
1021       \brief       \brief
# Line 1364  Data::unaryOp(UnaryFunction operation) Line 1381  Data::unaryOp(UnaryFunction operation)
1381    object (*this) is a rank n Data object, and returned object is a scalar.    object (*this) is a rank n Data object, and returned object is a scalar.
1382    Calls escript::algorithm.    Calls escript::algorithm.
1383  */  */
1384  template <class UnaryFunction>  template <class BinaryFunction>
1385  inline  inline
1386  double  double
1387  Data::algorithm(UnaryFunction operation) const  Data::algorithm(BinaryFunction operation, double initial_value) const
1388  {  {
1389    if (isExpanded()) {    if (isExpanded()) {
1390      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());
1391      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");
1392      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1393    } else if (isTagged()) {    } else if (isTagged()) {
1394      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());
1395      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");
1396      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1397    } else if (isConstant()) {    } else if (isConstant()) {
1398      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());
1399      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");
1400      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1401    }    }
1402    return 0;    return 0;
1403  }  }
# Line 1393  Data::algorithm(UnaryFunction operation) Line 1410  Data::algorithm(UnaryFunction operation)
1410    rank 0 Data object.    rank 0 Data object.
1411    Calls escript::dp_algorithm.    Calls escript::dp_algorithm.
1412  */  */
1413  template <class UnaryFunction>  template <class BinaryFunction>
1414  inline  inline
1415  Data  Data
1416  Data::dp_algorithm(UnaryFunction operation) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1417  {  {
1418    Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());    Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1419    if (isExpanded()) {    if (isExpanded()) {
# Line 1404  Data::dp_algorithm(UnaryFunction operati Line 1421  Data::dp_algorithm(UnaryFunction operati
1421      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1422      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1423      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1424      escript::dp_algorithm(*dataE,*resultE,operation);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1425    } else if (isTagged()) {    } else if (isTagged()) {
1426      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1427      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1428      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1429      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1430      escript::dp_algorithm(*dataT,*resultT,operation);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1431    } else if (isConstant()) {    } else if (isConstant()) {
1432      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1433      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1434      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1435      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1436      escript::dp_algorithm(*dataC,*resultC,operation);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1437    }    }
1438    return result;    return result;
1439  }  }

Legend:
Removed from v.126  
changed lines
  Added in v.149

  ViewVC Help
Powered by ViewVC 1.1.26