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

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

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

revision 1697 by jfenwick, Mon Aug 11 06:29:54 2008 UTC revision 1698 by jfenwick, Tue Aug 12 01:13:16 2008 UTC
# Line 24  Line 24 
24  #include "LocalOps.h"  #include "LocalOps.h"
25  #include "DataTypes.h"  #include "DataTypes.h"
26    
27    
28  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
29  #include <boost/python/object.hpp>  #include <boost/python/object.hpp>
30    
# Line 274  class DataArrayView { Line 275  class DataArrayView {
275    int    int
276    noValues() const;    noValues() const;
277    
278    /**  //  /**
279       \brief  //     \brief
280       Calculate the number of values for the given shape or region.  //     Calculate the number of values for the given shape or region.
281       This is purely a utility method and has no bearing on this view.  //     This is purely a utility method and has no bearing on this view.
282    */  //  */
283    ESCRIPT_DLL_API  //   ESCRIPT_DLL_API
284    static  //   static
285    int  //   int
286    noValues(const DataTypes::ShapeType& shape);  //   noValues(const DataTypes::ShapeType& shape);
287    //
288    ESCRIPT_DLL_API  //   ESCRIPT_DLL_API
289    static  //   static
290    int  //   int
291    noValues(const DataTypes::RegionLoopRangeType& region);  //   noValues(const DataTypes::RegionLoopRangeType& region);
292    
293    /**    /**
294       \brief       \brief
# Line 350  class DataArrayView { Line 351  class DataArrayView {
351    std::string    std::string
352    toString(const std::string& suffix=std::string("")) const;    toString(const std::string& suffix=std::string("")) const;
353    
354    /**  //  /**
355       \brief  //     \brief
356       Return the given shape as a string.  //     Return the given shape as a string.
357       This is purely a utility method and has no bearing on this view.  //     This is purely a utility method and has no bearing on this view.
358    //
359       \param shape - Input.  //     \param shape - Input.
360    */  //  */
361    ESCRIPT_DLL_API  //   ESCRIPT_DLL_API
362    static  //   static
363    std::string  //   std::string
364    shapeToString(const DataTypes::ShapeType& shape);  //   shapeToString(const DataTypes::ShapeType& shape);
365    
366    /**    /**
367      \brief      \brief
# Line 1680  DataTypes::ValueType::size_type Line 1681  DataTypes::ValueType::size_type
1681  DataArrayView::relIndex(DataTypes::ValueType::size_type i) const  DataArrayView::relIndex(DataTypes::ValueType::size_type i) const
1682  {  {
1683    EsysAssert((getRank()==1),"Incorrect number of indices for the rank of this object.");    EsysAssert((getRank()==1),"Incorrect number of indices for the rank of this object.");
1684    EsysAssert((i < noValues(m_shape)), "Error - Invalid index.");    EsysAssert((i < DataTypes::noValues(m_shape)), "Error - Invalid index.");
1685    return i;    return i;
1686  }  }
1687    
# Line 1689  DataTypes::ValueType::size_type Line 1690  DataTypes::ValueType::size_type
1690  DataArrayView::index(DataTypes::ValueType::size_type i) const  DataArrayView::index(DataTypes::ValueType::size_type i) const
1691  {  {
1692    EsysAssert((getRank()==1),"Incorrect number of indices for the rank of this object.");    EsysAssert((getRank()==1),"Incorrect number of indices for the rank of this object.");
1693    EsysAssert((i < noValues(m_shape)), "Error - Invalid index.");    EsysAssert((i < DataTypes::noValues(m_shape)), "Error - Invalid index.");
1694    return (m_offset+i);    return (m_offset+i);
1695  }  }
1696    
# Line 1700  DataArrayView::relIndex(DataTypes::Value Line 1701  DataArrayView::relIndex(DataTypes::Value
1701  {  {
1702    EsysAssert((getRank()==2),"Incorrect number of indices for the rank of this object.");    EsysAssert((getRank()==2),"Incorrect number of indices for the rank of this object.");
1703    DataTypes::ValueType::size_type temp=i+j*m_shape[0];    DataTypes::ValueType::size_type temp=i+j*m_shape[0];
1704    EsysAssert((temp < noValues(m_shape)), "Error - Invalid index.");    EsysAssert((temp < DataTypes::noValues(m_shape)), "Error - Invalid index.");
1705    return temp;    return temp;
1706  }  }
1707    
# Line 1711  DataArrayView::index(DataTypes::ValueTyp Line 1712  DataArrayView::index(DataTypes::ValueTyp
1712  {  {
1713    EsysAssert((getRank()==2),"Incorrect number of indices for the rank of this object.");    EsysAssert((getRank()==2),"Incorrect number of indices for the rank of this object.");
1714    DataTypes::ValueType::size_type temp=i+j*m_shape[0];    DataTypes::ValueType::size_type temp=i+j*m_shape[0];
1715    EsysAssert((temp < noValues(m_shape)), "Error - Invalid index.");    EsysAssert((temp < DataTypes::noValues(m_shape)), "Error - Invalid index.");
1716    return (m_offset+temp);    return (m_offset+temp);
1717  }  }
1718    
# Line 1723  DataArrayView::relIndex(DataTypes::Value Line 1724  DataArrayView::relIndex(DataTypes::Value
1724  {  {
1725    EsysAssert((getRank()==3),"Incorrect number of indices for the rank of this object.");    EsysAssert((getRank()==3),"Incorrect number of indices for the rank of this object.");
1726    DataTypes::ValueType::size_type temp=i+j*m_shape[0]+k*m_shape[1]*m_shape[0];    DataTypes::ValueType::size_type temp=i+j*m_shape[0]+k*m_shape[1]*m_shape[0];
1727    EsysAssert((temp < noValues(m_shape)), "Error - Invalid index.");    EsysAssert((temp < DataTypes::noValues(m_shape)), "Error - Invalid index.");
1728    return temp;    return temp;
1729  }  }
1730    
# Line 1735  DataArrayView::index(DataTypes::ValueTyp Line 1736  DataArrayView::index(DataTypes::ValueTyp
1736  {  {
1737    EsysAssert((getRank()==3),"Incorrect number of indices for the rank of this object.");    EsysAssert((getRank()==3),"Incorrect number of indices for the rank of this object.");
1738    DataTypes::ValueType::size_type temp=i+j*m_shape[0]+k*m_shape[1]*m_shape[0];    DataTypes::ValueType::size_type temp=i+j*m_shape[0]+k*m_shape[1]*m_shape[0];
1739    EsysAssert((temp < noValues(m_shape)), "Error - Invalid index.");    EsysAssert((temp < DataTypes::noValues(m_shape)), "Error - Invalid index.");
1740    return (m_offset+temp);    return (m_offset+temp);
1741  }  }
1742    
# Line 1748  DataArrayView::relIndex(DataTypes::Value Line 1749  DataArrayView::relIndex(DataTypes::Value
1749  {  {
1750    EsysAssert((getRank()==4),"Incorrect number of indices for the rank of this object.");    EsysAssert((getRank()==4),"Incorrect number of indices for the rank of this object.");
1751    DataTypes::ValueType::size_type temp=i+j*m_shape[0]+k*m_shape[1]*m_shape[0]+m*m_shape[2]*m_shape[1]*m_shape[0];    DataTypes::ValueType::size_type temp=i+j*m_shape[0]+k*m_shape[1]*m_shape[0]+m*m_shape[2]*m_shape[1]*m_shape[0];
1752    EsysAssert((temp < noValues(m_shape)), "Error - Invalid index.");    EsysAssert((temp < DataTypes::noValues(m_shape)), "Error - Invalid index.");
1753    return temp;    return temp;
1754  }  }
1755    
# Line 1761  DataArrayView::index(DataTypes::ValueTyp Line 1762  DataArrayView::index(DataTypes::ValueTyp
1762  {  {
1763    EsysAssert((getRank()==4),"Incorrect number of indices for the rank of this object.");    EsysAssert((getRank()==4),"Incorrect number of indices for the rank of this object.");
1764    DataTypes::ValueType::size_type temp=i+j*m_shape[0]+k*m_shape[1]*m_shape[0]+m*m_shape[2]*m_shape[1]*m_shape[0];    DataTypes::ValueType::size_type temp=i+j*m_shape[0]+k*m_shape[1]*m_shape[0]+m*m_shape[2]*m_shape[1]*m_shape[0];
1765    EsysAssert((temp < noValues(m_shape)), "Error - Invalid index.");    EsysAssert((temp < DataTypes::noValues(m_shape)), "Error - Invalid index.");
1766    return (m_offset+temp);    return (m_offset+temp);
1767  }  }
1768    

Legend:
Removed from v.1697  
changed lines
  Added in v.1698

  ViewVC Help
Powered by ViewVC 1.1.26