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

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

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

revision 123 by jgs, Fri Jul 8 04:08:13 2005 UTC revision 151 by jgs, Thu Sep 22 01:55:00 2005 UTC
# Line 48  class DataBlocks2D { Line 48  class DataBlocks2D {
48    
49       Description:       Description:
50       Default constructor for DataBlocks2D.       Default constructor for DataBlocks2D.
51       Creates a 0 * 0 array of data points with 0 values.       Creates an empty DataBlocks2D object.
52    */    */
53    DataBlocks2D();    DataBlocks2D();
54    
# Line 68  class DataBlocks2D { Line 68  class DataBlocks2D {
68       Description:       Description:
69       Constructor for DataBlocks2D.       Constructor for DataBlocks2D.
70    
71       \param numRows - Input - Number of rows.       \param numRows - Input - Number of rows(samples).
72       \param numCols - Input - Number of columns.       \param numCols - Input - Number of columns(data-points per sample).
73       \param blockSize - Input - Number of elements per block.       \param blockSize - Input - Number of elements per block(per data-point).
74    
75         All parameters must be >0, else an exception will be thrown.
76    */    */
77    DataBlocks2D(int numRows, int numCols, int blockSize);    DataBlocks2D(int numRows, int numCols, int blockSize);
78    
# Line 124  class DataBlocks2D { Line 126  class DataBlocks2D {
126       \param numRows - Input - Number of rows.       \param numRows - Input - Number of rows.
127       \param numCols - Input - Number of columns.       \param numCols - Input - Number of columns.
128       \param blockSize - Input - Number of elements per block.       \param blockSize - Input - Number of elements per block.
129    
130         All parameters must be >0, else an exception will be thrown.
131    */    */
132    void    void
133    resize(int numRows, int numCols, int blockSize);    resize(int numRows, int numCols, int blockSize);
# Line 191  class DataBlocks2D { Line 195  class DataBlocks2D {
195    getData();    getData();
196    
197    inline    inline
198    const    const ValueType&
   ValueType&  
199    getData() const;    getData() const;
200    
201    /**    /**
# Line 229  class DataBlocks2D { Line 232  class DataBlocks2D {
232    ValueType m_data;    ValueType m_data;
233    
234    //    //
   // The number of values per data point.  
   ValueType::size_type m_blockSize;  
   
   //  
235    // The dimensions of the 2D array of data points.    // The dimensions of the 2D array of data points.
236    ValueType::size_type m_numRows;    ValueType::size_type m_numRows;
237    ValueType::size_type m_numCols;    ValueType::size_type m_numCols;
238    
239      //
240      // The number of values per data point.
241      ValueType::size_type m_blockSize;
242    
243  };  };
244    
245  inline  inline
246  DataBlocks2D::ValueType::size_type  DataBlocks2D::ValueType::size_type
247  DataBlocks2D::size() const  DataBlocks2D::size() const
248  {  {
249    return m_data.size();      EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
250        return m_data.size();
251  }  }
252    
253  inline  inline
254  DataBlocks2D::ValueType::size_type  DataBlocks2D::ValueType::size_type
255  DataBlocks2D::getNumRows() const  DataBlocks2D::getNumRows() const
256  {  {
257    return m_numRows;      EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
258        return m_numRows;
259  }  }
260    
261  inline  inline
262  DataBlocks2D::ValueType::size_type  DataBlocks2D::ValueType::size_type
263  DataBlocks2D::getNumCols() const  DataBlocks2D::getNumCols() const
264  {  {
265    return m_numCols;      EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
266        return m_numCols;
267  }  }
268    
269  inline  inline
270  DataBlocks2D::ValueType::size_type  DataBlocks2D::ValueType::size_type
271  DataBlocks2D::getBlockSize() const  DataBlocks2D::getBlockSize() const
272  {  {
273    return m_blockSize;      EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
274        return m_blockSize;
275  }  }
276    
277  inline  inline
278  DataBlocks2D::ValueType::size_type  DataBlocks2D::ValueType::size_type
279  DataBlocks2D::index(int row, int col) const  DataBlocks2D::index(int row, int col) const
280  {  {
281        EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
282      EsysAssert(((row >= 0) && (col >= 0) && (m_data.size() > 0)), "(DataBlocks2D) Index value out of range.");      EsysAssert(((row >= 0) && (col >= 0) && (m_data.size() > 0)), "(DataBlocks2D) Index value out of range.");
283      ValueType::size_type temp=(row*m_numCols+col)*m_blockSize;      ValueType::size_type temp=(row*m_numCols+col)*m_blockSize;
284      EsysAssert((temp <= (m_data.size()-m_blockSize)), "(DataBlocks2D) Index value out of range.");      EsysAssert((temp <= (m_data.size()-m_blockSize)), "(DataBlocks2D) Index value out of range.");
# Line 281  inline Line 289  inline
289  DataBlocks2D::ValueType::reference  DataBlocks2D::ValueType::reference
290  DataBlocks2D::operator[](DataBlocks2D::ValueType::size_type i)  DataBlocks2D::operator[](DataBlocks2D::ValueType::size_type i)
291  {  {
292        EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
293      return m_data[i];      return m_data[i];
294  }  }
295    
# Line 288  inline Line 297  inline
297  DataBlocks2D::ValueType::const_reference  DataBlocks2D::ValueType::const_reference
298  DataBlocks2D::operator[](DataBlocks2D::ValueType::size_type i) const  DataBlocks2D::operator[](DataBlocks2D::ValueType::size_type i) const
299  {  {
300        EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
301      return m_data[i];      return m_data[i];
302  }  }
303    
# Line 295  inline Line 305  inline
305  DataBlocks2D::ValueType::reference  DataBlocks2D::ValueType::reference
306  DataBlocks2D::operator()(int row, int col)  DataBlocks2D::operator()(int row, int col)
307  {  {
308        EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
309      return m_data[index(row,col)];      return m_data[index(row,col)];
310  }  }
311    
# Line 302  inline Line 313  inline
313  DataBlocks2D::ValueType::const_reference  DataBlocks2D::ValueType::const_reference
314  DataBlocks2D::operator()(int row, int col) const  DataBlocks2D::operator()(int row, int col) const
315  {  {
316        EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
317      return m_data[index(row,col)];      return m_data[index(row,col)];
318  }  }
319    
# Line 309  inline Line 321  inline
321  DataBlocks2D::ValueType&  DataBlocks2D::ValueType&
322  DataBlocks2D::getData()  DataBlocks2D::getData()
323  {  {
324        EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
325      return m_data;      return m_data;
326  }  }
327    
# Line 316  inline Line 329  inline
329  const DataBlocks2D::ValueType&  const DataBlocks2D::ValueType&
330  DataBlocks2D::getData() const  DataBlocks2D::getData() const
331  {  {
332        EsysAssert(((m_numRows >= 0) && (m_numCols >= 0) && (m_blockSize >= 0)), "(DataBlocks2D) Invalid object.");
333      return m_data;      return m_data;
334  }  }
335    

Legend:
Removed from v.123  
changed lines
  Added in v.151

  ViewVC Help
Powered by ViewVC 1.1.26