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

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

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

revision 853 by ksteube, Mon Aug 21 02:08:47 2006 UTC revision 854 by gross, Thu Sep 21 05:29:42 2006 UTC
# Line 70  class Data { Line 70  class Data {
70    typedef double (*UnaryDFunPtr)(double);    typedef double (*UnaryDFunPtr)(double);
71    typedef double (*BinaryDFunPtr)(double,double);    typedef double (*BinaryDFunPtr)(double,double);
72    
73    
74    /**    /**
75       Constructors.       Constructors.
76    */    */
# Line 671  class Data { Line 672  class Data {
672    
673    /**    /**
674       \brief       \brief
675         Returns 1./ Data object
676         *
677      */
678      ESCRIPT_DLL_API
679      Data
680      oneOver() const;
681      /**
682         \brief
683       Return a Data with a 1 for +ive values and a 0 for 0 or -ive values.       Return a Data with a 1 for +ive values and a 0 for 0 or -ive values.
684       *       *
685    */    */
# Line 1345  class Data { Line 1354  class Data {
1354    
1355    /**    /**
1356       \brief       \brief
      Perform the given binary operation on all of the data's elements.  
      RHS is a boost::python object.  
   */  
   template <class BinaryFunction>  
   inline  
   void  
   binaryOp(const boost::python::object& right,  
            BinaryFunction operation);  
   
   /**  
      \brief  
1357       Convert the data type of the RHS to match this.       Convert the data type of the RHS to match this.
1358       \param right - Input - data type to match.       \param right - Input - data type to match.
1359    */    */
# Line 1380  class Data { Line 1378  class Data {
1378               const FunctionSpace& what,               const FunctionSpace& what,
1379               bool expanded);               bool expanded);
1380    
   /**  
      \brief  
      Reshape the data point if the data point is currently rank 0.  
      Will throw an exception if the data points are not rank 0.  
      The original data point value is used for all values of the new  
      data point.  
   */  
   void  
   reshapeDataPoint(const DataArrayView::ShapeType& shape);  
   
1381    //    //
1382    // flag to protect the data object against any update    // flag to protect the data object against any update
1383    bool m_protected;    bool m_protected;
# Line 1429  Data::initialise(const IValueType& value Line 1417  Data::initialise(const IValueType& value
1417  /**  /**
1418     Binary Data object operators.     Binary Data object operators.
1419  */  */
1420    inline double rpow(double x,double y)
1421    {
1422        return pow(y,x);
1423    };
1424    
1425  /**  /**
1426    \brief    \brief
# Line 1565  Data::binaryOp(const Data& right, Line 1557  Data::binaryOp(const Data& right,
1557     //     //
1558     // 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
1559     if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) {     if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) {
1560       reshapeDataPoint(right.getPointDataView().getShape());       throw DataException("Error - attempt to update rank zero object with object with rank bigger than zero.");
1561     }     }
1562     //     //
1563     // initially make the temporary a shallow copy     // initially make the temporary a shallow copy
# Line 1617  Data::binaryOp(const Data& right, Line 1609  Data::binaryOp(const Data& right,
1609       EsysAssert((leftC!=0 && rightC!=0), "Programming error - casting to DataConstant.");       EsysAssert((leftC!=0 && rightC!=0), "Programming error - casting to DataConstant.");
1610       escript::binaryOp(*leftC,*rightC,operation);       escript::binaryOp(*leftC,*rightC,operation);
1611     }     }
1612  }     #if defined DOPROF
1613       profData->binary++;
1614  /**     #endif
   \brief  
   Perform the given binary operation with this and right as operands.  
   Right is a boost::python object.  
 */  
 template <class BinaryFunction>  
 inline  
 void  
 Data::binaryOp(const boost::python::object& right,  
                BinaryFunction operation)  
 {  
    DataArray temp(right);  
    //  
    // if this has a rank of zero promote it to the rank of the RHS.  
    if (getPointDataView().getRank()==0 && temp.getView().getRank()!=0) {  
       reshapeDataPoint(temp.getView().getShape());  
    }  
    //  
    // Always allow scalar values for the RHS but check other shapes  
    if (temp.getView().getRank()!=0) {  
      if (!getPointDataView().checkShape(temp.getView().getShape())) {  
        throw DataException(getPointDataView().createShapeErrorMessage(  
                   "Error - RHS shape doesn't match LHS shape.",temp.getView().getShape()));  
      }  
    }  
    if (isExpanded()) {  
      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());  
      EsysAssert((leftC!=0),"Programming error - casting to DataExpanded.");  
      escript::binaryOp(*leftC,temp.getView(),operation);  
    } else if (isTagged()) {  
      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());  
      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");  
      escript::binaryOp(*leftC,temp.getView(),operation);  
    } else if (isConstant()) {  
      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());  
      EsysAssert((leftC!=0),"Programming error - casting to DataConstant.");  
      escript::binaryOp(*leftC,temp.getView(),operation);  
    }  
1615  }  }
1616    
1617  /**  /**

Legend:
Removed from v.853  
changed lines
  Added in v.854

  ViewVC Help
Powered by ViewVC 1.1.26