Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
Nektar::Array< TwoD, const DataType > Class Template Reference

2D array with garbage collection and bounds checking. More...

#include <SharedArray.hpp>

Inheritance diagram for Nektar::Array< TwoD, const DataType >:
Inheritance graph
[legend]

Public Types

typedef boost::multi_array_ref
< DataType, 2 > 
ArrayType
 
typedef ArrayType::const_reference const_reference
 
typedef ArrayType::reference reference
 
typedef ArrayType::index index
 
typedef ArrayType::const_iterator const_iterator
 
typedef ArrayType::iterator iterator
 
typedef ArrayType::element element
 
typedef ArrayType::size_type size_type
 

Public Member Functions

 Array ()
 
 Array (unsigned int dim1Size, unsigned int dim2Size)
 Constructs a 3 dimensional array. The elements of the array are not initialized. More...
 
 Array (unsigned int dim1Size, unsigned int dim2Size, const DataType &initValue)
 
 Array (unsigned int dim1Size, unsigned int dim2Size, const DataType *data)
 
 Array (const Array< TwoD, const DataType > &rhs)
 
Array< TwoD, const DataType > & operator= (const Array< TwoD, const DataType > &rhs)
 
const_iterator begin () const
 
const_iterator end () const
 
const_reference operator[] (index i) const
 
const elementget () const
 
const elementdata () const
 
size_type num_dimensions () const
 
const size_typeshape () const
 
size_type num_elements () const
 
size_type GetRows () const
 
size_type GetColumns () const
 

Protected Attributes

boost::shared_ptr< ArrayTypem_data
 

Friends

template<typename T >
bool operator== (const Array< TwoD, T > &, const Array< TwoD, T > &)
 
bool operator== (const Array< TwoD, NekDouble > &, const Array< TwoD, NekDouble > &)
 
bool IsEqual (const Array< TwoD, const NekDouble > &, const Array< TwoD, const NekDouble > &, NekDouble)
 

Detailed Description

template<typename DataType>
class Nektar::Array< TwoD, const DataType >

2D array with garbage collection and bounds checking.

Definition at line 319 of file SharedArray.hpp.

Member Typedef Documentation

template<typename DataType >
typedef boost::multi_array_ref<DataType, 2> Nektar::Array< TwoD, const DataType >::ArrayType

Definition at line 322 of file SharedArray.hpp.

template<typename DataType >
typedef ArrayType::const_iterator Nektar::Array< TwoD, const DataType >::const_iterator

Definition at line 327 of file SharedArray.hpp.

template<typename DataType >
typedef ArrayType::const_reference Nektar::Array< TwoD, const DataType >::const_reference

Definition at line 323 of file SharedArray.hpp.

template<typename DataType >
typedef ArrayType::element Nektar::Array< TwoD, const DataType >::element

Definition at line 330 of file SharedArray.hpp.

template<typename DataType >
typedef ArrayType::index Nektar::Array< TwoD, const DataType >::index

Definition at line 326 of file SharedArray.hpp.

template<typename DataType >
typedef ArrayType::iterator Nektar::Array< TwoD, const DataType >::iterator

Definition at line 328 of file SharedArray.hpp.

template<typename DataType >
typedef ArrayType::reference Nektar::Array< TwoD, const DataType >::reference

Definition at line 324 of file SharedArray.hpp.

template<typename DataType >
typedef ArrayType::size_type Nektar::Array< TwoD, const DataType >::size_type

Definition at line 331 of file SharedArray.hpp.

Constructor & Destructor Documentation

template<typename DataType >
Nektar::Array< TwoD, const DataType >::Array ( )
inline

Definition at line 336 of file SharedArray.hpp.

336  :
337  m_data(CreateStorage<DataType>(0, 0))
338  {
339  }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
Nektar::Array< TwoD, const DataType >::Array ( unsigned int  dim1Size,
unsigned int  dim2Size 
)
inline

Constructs a 3 dimensional array. The elements of the array are not initialized.

Definition at line 342 of file SharedArray.hpp.

342  :
343  m_data(CreateStorage<DataType>(dim1Size, dim2Size))
344  {
345  ArrayInitializationPolicy<DataType>::Initialize(m_data->data(), m_data->num_elements());
346  }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
Nektar::Array< TwoD, const DataType >::Array ( unsigned int  dim1Size,
unsigned int  dim2Size,
const DataType &  initValue 
)
inline

Definition at line 348 of file SharedArray.hpp.

348  :
349  m_data(CreateStorage<DataType>(dim1Size, dim2Size))
350  {
351  ArrayInitializationPolicy<DataType>::Initialize(m_data->data(), m_data->num_elements(), initValue);
352  }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
Nektar::Array< TwoD, const DataType >::Array ( unsigned int  dim1Size,
unsigned int  dim2Size,
const DataType *  data 
)
inline

Definition at line 354 of file SharedArray.hpp.

354  :
355  m_data(CreateStorage<DataType>(dim1Size, dim2Size))
356  {
357  ArrayInitializationPolicy<DataType>::Initialize(m_data->data(), m_data->num_elements(), data);
358  }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
Nektar::Array< TwoD, const DataType >::Array ( const Array< TwoD, const DataType > &  rhs)
inline

Definition at line 360 of file SharedArray.hpp.

360  :
361  m_data(rhs.m_data)
362  {
363  }
boost::shared_ptr< ArrayType > m_data

Member Function Documentation

template<typename DataType >
const_iterator Nektar::Array< TwoD, const DataType >::begin ( ) const
inline

Definition at line 376 of file SharedArray.hpp.

376 { return m_data->begin(); }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
const element* Nektar::Array< TwoD, const DataType >::data ( ) const
inline

Definition at line 380 of file SharedArray.hpp.

380 { return m_data->data(); }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
const_iterator Nektar::Array< TwoD, const DataType >::end ( ) const
inline

Definition at line 377 of file SharedArray.hpp.

377 { return m_data->end(); }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
const element* Nektar::Array< TwoD, const DataType >::get ( ) const
inline

Definition at line 379 of file SharedArray.hpp.

379 { return m_data->data(); }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
size_type Nektar::Array< TwoD, const DataType >::GetColumns ( ) const
inline

Definition at line 386 of file SharedArray.hpp.

386 { return m_data->shape()[1]; }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
size_type Nektar::Array< TwoD, const DataType >::GetRows ( ) const
inline

Definition at line 385 of file SharedArray.hpp.

385 { return m_data->shape()[0]; }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
size_type Nektar::Array< TwoD, const DataType >::num_dimensions ( ) const
inline

Definition at line 381 of file SharedArray.hpp.

381 { return m_data->num_dimensions(); }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
size_type Nektar::Array< TwoD, const DataType >::num_elements ( ) const
inline

Definition at line 383 of file SharedArray.hpp.

383 { return m_data->num_elements(); }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
Array<TwoD, const DataType>& Nektar::Array< TwoD, const DataType >::operator= ( const Array< TwoD, const DataType > &  rhs)
inline

Definition at line 365 of file SharedArray.hpp.

References m_data.

366  {
367  m_data = rhs.m_data;
368  return *this;
369  }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
const_reference Nektar::Array< TwoD, const DataType >::operator[] ( index  i) const
inline

Definition at line 378 of file SharedArray.hpp.

378 { return (*m_data)[i]; }
boost::shared_ptr< ArrayType > m_data
template<typename DataType >
const size_type* Nektar::Array< TwoD, const DataType >::shape ( ) const
inline

Definition at line 382 of file SharedArray.hpp.

382 { return m_data->shape(); }
boost::shared_ptr< ArrayType > m_data

Friends And Related Function Documentation

template<typename DataType >
bool IsEqual ( const Array< TwoD, const NekDouble > &  ,
const Array< TwoD, const NekDouble > &  ,
NekDouble   
)
friend

Definition at line 76 of file ArrayEqualityComparison.cpp.

79  {
80  if( (lhs.GetRows() != rhs.GetRows()) ||
81  (lhs.GetColumns() != rhs.GetColumns()) )
82  {
83  return false;
84  }
85 
86  if( lhs.data() == rhs.data() )
87  {
88  return true;
89  }
90 
91  for(unsigned int i = 0; i < lhs.GetRows(); ++i)
92  {
93  for(unsigned int j = 0; j < lhs.GetColumns(); ++j)
94  {
95  if( fabs(lhs[i][j]-rhs[i][j]) > tol )
96  {
97  return false;
98  }
99  }
100  }
101 
102  return true;
103  }
StandardMatrixTag & lhs
template<typename DataType >
template<typename T >
bool operator== ( const Array< TwoD, T > &  ,
const Array< TwoD, T > &   
)
friend
template<typename DataType >
bool operator== ( const Array< TwoD, NekDouble > &  ,
const Array< TwoD, NekDouble > &   
)
friend

Definition at line 71 of file ArrayEqualityComparison.cpp.

72  {
73  return IsEqual(lhs,rhs);
74  }
StandardMatrixTag & lhs
friend bool IsEqual(const Array< TwoD, const NekDouble > &, const Array< TwoD, const NekDouble > &, NekDouble)

Member Data Documentation

template<typename DataType >
boost::shared_ptr<ArrayType> Nektar::Array< TwoD, const DataType >::m_data
protected

Definition at line 389 of file SharedArray.hpp.

Referenced by operator=(), and Nektar::operator==().