/[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 804 by gross, Thu Aug 10 01:12:16 2006 UTC revision 876 by ksteube, Thu Oct 19 03:50:23 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 880  class Data { Line 889  class Data {
889    
890    /**    /**
891       \brief       \brief
892         Return the error function erf of each data point of this Data object.
893         *
894      */
895      ESCRIPT_DLL_API
896      Data
897      erf() const;
898    
899      /**
900         \brief
901       Return the sin of each data point of this Data object.       Return the sin of each data point of this Data object.
902       *       *
903    */    */
# Line 1279  class Data { Line 1297  class Data {
1297    ESCRIPT_DLL_API    ESCRIPT_DLL_API
1298      MPI_Comm      MPI_Comm
1299      get_MPIComm(void) const;      get_MPIComm(void) const;
1300        
1301      /**
1302         \brief
1303         return the object produced by the factory, which is a DataConstant or DataExpanded
1304      */
1305      ESCRIPT_DLL_API
1306        DataAbstract*
1307        borrowData(void) const;
1308    
1309   protected:   protected:
1310    
1311   private:   private:
# Line 1337  class Data { Line 1363  class Data {
1363    
1364    /**    /**
1365       \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  
1366       Convert the data type of the RHS to match this.       Convert the data type of the RHS to match this.
1367       \param right - Input - data type to match.       \param right - Input - data type to match.
1368    */    */
# Line 1372  class Data { Line 1387  class Data {
1387               const FunctionSpace& what,               const FunctionSpace& what,
1388               bool expanded);               bool expanded);
1389    
   /**  
      \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);  
   
1390    //    //
1391    // flag to protect the data object against any update    // flag to protect the data object against any update
1392    bool m_protected;    bool m_protected;
# Line 1421  Data::initialise(const IValueType& value Line 1426  Data::initialise(const IValueType& value
1426  /**  /**
1427     Binary Data object operators.     Binary Data object operators.
1428  */  */
1429    inline double rpow(double x,double y)
1430    {
1431        return pow(y,x);
1432    };
1433    
1434  /**  /**
1435    \brief    \brief
# Line 1522  ESCRIPT_DLL_API std::ostream& operator<< Line 1531  ESCRIPT_DLL_API std::ostream& operator<<
1531    
1532  /**  /**
1533    \brief    \brief
1534      Compute a tensor product of two Data objects
1535      \param arg0 - Input - Data object
1536      \param arg1 - Input - Data object
1537      \param axis_offset - Input - axis offset
1538      \param transpose - Input - 0: transpose neither, 1: transpose arg0, 2: transpose arg1
1539    */
1540    ESCRIPT_DLL_API
1541    Data
1542    C_GeneralTensorProduct(Data& arg0,
1543                         Data& arg1,
1544                         int axis_offset=0,
1545                         int transpose=0);
1546    
1547    /**
1548      \brief
1549    Return true if operands are equivalent, else return false.    Return true if operands are equivalent, else return false.
1550    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
1551    be relied on. Requires further implementation.    be relied on. Requires further implementation.
# Line 1542  Data::binaryOp(const Data& right, Line 1566  Data::binaryOp(const Data& right,
1566     //     //
1567     // 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
1568     if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) {     if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) {
1569       reshapeDataPoint(right.getPointDataView().getShape());       throw DataException("Error - attempt to update rank zero object with object with rank bigger than zero.");
1570     }     }
1571     //     //
1572     // initially make the temporary a shallow copy     // initially make the temporary a shallow copy
# Line 1594  Data::binaryOp(const Data& right, Line 1618  Data::binaryOp(const Data& right,
1618       EsysAssert((leftC!=0 && rightC!=0), "Programming error - casting to DataConstant.");       EsysAssert((leftC!=0 && rightC!=0), "Programming error - casting to DataConstant.");
1619       escript::binaryOp(*leftC,*rightC,operation);       escript::binaryOp(*leftC,*rightC,operation);
1620     }     }
1621  }     #if defined DOPROF
1622       profData->binary++;
1623  /**     #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);  
    }  
1624  }  }
1625    
1626  /**  /**

Legend:
Removed from v.804  
changed lines
  Added in v.876

  ViewVC Help
Powered by ViewVC 1.1.26