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

1D Array More...

#include <SharedArray.hpp>

Inheritance diagram for Nektar::Array< OneD, DataType >:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Array< OneD, DataType >:
Collaboration graph
[legend]

Public Types

typedef Array< OneD, const
DataType > 
BaseType
typedef BaseType::iterator iterator
typedef BaseType::reference reference
typedef BaseType::size_type size_type
typedef BaseType::element element
- Public Types inherited from Nektar::Array< OneD, const DataType >
typedef DataType * ArrayType
typedef const DataType & const_reference
typedef DataType & reference
typedef const DataType * const_iterator
typedef DataType * iterator
typedef DataType element
typedef unsigned int size_type

Public Member Functions

 Array ()
 Creates an empty array.
 Array (unsigned int dim1Size)
 Creates an array of size dim1Size.
 Array (unsigned int dim1Size, const DataType &initValue)
 Creates a 1D array with each element initialized to an initial value.
 Array (unsigned int dim1Size, const DataType *data)
 Creates a 1D array a copies data into it.
 Array (unsigned int dim1Size, const Array< OneD, DataType > &rhs)
 Array (unsigned int dim1Size, const Array< OneD, const DataType > &rhs)
 Creates a 1D array that references rhs.
 Array (const Array< OneD, DataType > &rhs)
 Array (const Array< OneD, const DataType > &rhs)
 Creates a reference to rhs.
Array< OneD, DataType > & operator= (const Array< OneD, DataType > &rhs)
iterator begin ()
iterator end ()
reference operator[] (unsigned int i)
elementget ()
elementdata ()
- Public Member Functions inherited from Nektar::Array< OneD, const DataType >
 ~Array ()
Array< OneD, const DataType > & operator= (const Array< OneD, const DataType > &rhs)
 Creates a reference to rhs.
const_iterator begin () const
const_iterator end () const
const_reference operator[] (unsigned int i) const
const elementget () const
 Returns a c-style pointer to the underlying array.
const elementdata () const
 Returns a c-style pointer to the underlying array.
size_type num_dimensions () const
 Returns 1.
size_type num_elements () const
 Returns the array's size.
size_type capacity () const
unsigned int GetOffset () const
 Returns the array's offset.
bool Overlaps (const Array< OneD, const DataType > &rhs) const
 Returns true is this array and rhs overlap.

Static Public Member Functions

static Array< OneD, DataType > CreateWithOffset (const Array< OneD, DataType > &rhs, unsigned int offset)

Protected Member Functions

 Array (const Array< OneD, const DataType > &rhs, AllowWrappingOfConstArrays a)
void ChangeSize (unsigned int newSize)

Friends

class NekVector
class NekMatrix
class LinearSystem

Additional Inherited Members

- Protected Attributes inherited from Nektar::Array< OneD, const DataType >
unsigned int m_size
unsigned int m_capacity
DataType * m_data
unsigned int * m_count
unsigned int m_offset

Detailed Description

template<typename DataType>
class Nektar::Array< OneD, DataType >

1D Array

pageNekArrays

Misc notes.

Throught the 1D Array class you will see things like "using BaseType::begin" and "using BaseType::end". This is necessary to bring the methods from the ConstArray into scope in Array class. Typically this is not necessary, but since we have method names which match those in the base class, the base class names are hidden. Therefore, we have to explicitly bring them into scope to use them.

Definition at line 477 of file SharedArray.hpp.

Member Typedef Documentation

template<typename DataType >
typedef Array<OneD, const DataType> Nektar::Array< OneD, DataType >::BaseType

Definition at line 480 of file SharedArray.hpp.

template<typename DataType >
typedef BaseType::element Nektar::Array< OneD, DataType >::element

Definition at line 484 of file SharedArray.hpp.

template<typename DataType >
typedef BaseType::iterator Nektar::Array< OneD, DataType >::iterator

Definition at line 481 of file SharedArray.hpp.

template<typename DataType >
typedef BaseType::reference Nektar::Array< OneD, DataType >::reference

Definition at line 482 of file SharedArray.hpp.

template<typename DataType >
typedef BaseType::size_type Nektar::Array< OneD, DataType >::size_type

Definition at line 483 of file SharedArray.hpp.

Constructor & Destructor Documentation

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

Creates an empty array.

Reimplemented from Nektar::Array< OneD, const DataType >.

Definition at line 487 of file SharedArray.hpp.

:
{
}
template<typename DataType >
Nektar::Array< OneD, DataType >::Array ( unsigned int  dim1Size)
inlineexplicit

Creates an array of size dim1Size.

If DataType is a fundamental type (double, int, etc.), then the allocated array is uninitialized. If it is any other type, each element is initialized with DataType's default constructor.

Reimplemented from Nektar::Array< OneD, const DataType >.

Definition at line 492 of file SharedArray.hpp.

:
BaseType(dim1Size)
{
}
template<typename DataType >
Nektar::Array< OneD, DataType >::Array ( unsigned int  dim1Size,
const DataType &  initValue 
)
inline

Creates a 1D array with each element initialized to an initial value.

Parameters
dim1SizeThe array's size.
initValueEach element's initial value.

If DataType is a fundamental type (double, int, etc.), then the initial value is copied directly into each element. Otherwise, the DataType's copy constructor is used to initialize each element.

Reimplemented from Nektar::Array< OneD, const DataType >.

Definition at line 497 of file SharedArray.hpp.

:
BaseType(dim1Size, initValue)
{
}
template<typename DataType >
Nektar::Array< OneD, DataType >::Array ( unsigned int  dim1Size,
const DataType *  data 
)
inline

Creates a 1D array a copies data into it.

Parameters
dim1Sizethe array's size.
dataThe data to copy.

If DataType is a fundamental type (double, int, etc.), then data is copied directly into the underlying storage. Otherwise, the DataType's copy constructor is used to copy each element.

Reimplemented from Nektar::Array< OneD, const DataType >.

Definition at line 502 of file SharedArray.hpp.

:
BaseType(dim1Size, data)
{
}
template<typename DataType >
Nektar::Array< OneD, DataType >::Array ( unsigned int  dim1Size,
const Array< OneD, DataType > &  rhs 
)
inline

Definition at line 507 of file SharedArray.hpp.

:
BaseType(dim1Size, rhs)
{
}
template<typename DataType >
Nektar::Array< OneD, DataType >::Array ( unsigned int  dim1Size,
const Array< OneD, const DataType > &  rhs 
)
inline

Creates a 1D array that references rhs.

Parameters
dim1SizeThe size of the array. This is useful when you want this array to reference a subset of the elements in rhs.
rhsArray to reference. This constructor creates an array that references rhs. Any changes to rhs will be reflected in this array. The memory for the array will only be deallocated when both rhs and this array have gone out of scope.

Reimplemented from Nektar::Array< OneD, const DataType >.

Definition at line 512 of file SharedArray.hpp.

:
BaseType(dim1Size, rhs.data())
{
}
template<typename DataType >
Nektar::Array< OneD, DataType >::Array ( const Array< OneD, DataType > &  rhs)
inline

Definition at line 517 of file SharedArray.hpp.

:
BaseType(rhs)
{
}
template<typename DataType >
Nektar::Array< OneD, DataType >::Array ( const Array< OneD, const DataType > &  rhs)
inline

Creates a reference to rhs.

Reimplemented from Nektar::Array< OneD, const DataType >.

Definition at line 522 of file SharedArray.hpp.

:
BaseType(rhs.num_elements(), rhs.data())
{
}
template<typename DataType >
Nektar::Array< OneD, DataType >::Array ( const Array< OneD, const DataType > &  rhs,
AllowWrappingOfConstArrays  a 
)
inlineprotected

Definition at line 572 of file SharedArray.hpp.

:
BaseType(rhs)
{
}

Member Function Documentation

template<typename DataType >
iterator Nektar::Array< OneD, DataType >::begin ( )
inline

Definition at line 542 of file SharedArray.hpp.

Referenced by Nektar::NekVector< DataType >::NekVector().

{ return this->m_data + 1 +this->m_offset; }
template<typename DataType >
void Nektar::Array< OneD, DataType >::ChangeSize ( unsigned int  newSize)
inlineprotected

Definition at line 577 of file SharedArray.hpp.

References ASSERTL1.

{
ASSERTL1(newSize <= this->m_capacity, "Can't change an array size to something larger than its capacity.");
this->m_size = newSize;
}
template<typename DataType >
static Array<OneD, DataType> Nektar::Array< OneD, DataType >::CreateWithOffset ( const Array< OneD, DataType > &  rhs,
unsigned int  offset 
)
inlinestatic

Definition at line 533 of file SharedArray.hpp.

References Nektar::Array< OneD, const DataType >::m_offset, and Nektar::Array< OneD, const DataType >::m_size.

{
Array<OneD, DataType> result(rhs);
result.m_offset += offset;
result.m_size = rhs.m_size - offset;
return result;
}
template<typename DataType >
element* Nektar::Array< OneD, DataType >::data ( )
inline

Definition at line 561 of file SharedArray.hpp.

Referenced by Nektar::LibUtilities::GaussPoints::CalculateInterpMatrix(), Nektar::LibUtilities::GaussPoints::CalculatePoints(), Nektar::CopyArray(), Nektar::CopyArrayN(), Nektar::NekMatrix< DataType, StandardMatrixTag >::operator=(), and Nektar::NekMatrix< DataType, StandardMatrixTag >::ResizeDataArrayIfNeeded().

{ return this->m_data + 1 +this->m_offset; }
template<typename DataType >
iterator Nektar::Array< OneD, DataType >::end ( )
inline

Definition at line 545 of file SharedArray.hpp.

{ return this->m_data + 1 + this->m_offset + this->m_size; }
template<typename DataType >
element* Nektar::Array< OneD, DataType >::get ( )
inline

Definition at line 558 of file SharedArray.hpp.

Referenced by Nektar::FullBlockMatrixMultiply(), Nektar::FullMatrixFuncs::Invert(), and Nektar::NekVector< DataType >::NekVector().

{ return this->m_data + 1 +this->m_offset; }
template<typename DataType >
Array<OneD, DataType>& Nektar::Array< OneD, DataType >::operator= ( const Array< OneD, DataType > &  rhs)
inline

Definition at line 527 of file SharedArray.hpp.

{
BaseType::operator=(rhs);
return *this;
}
template<typename DataType >
reference Nektar::Array< OneD, DataType >::operator[] ( unsigned int  i)
inline

Definition at line 548 of file SharedArray.hpp.

References ASSERTL1.

{
ASSERTL1(static_cast<size_type>(i) < this->num_elements(), (std::string("Element ") +
boost::lexical_cast<std::string>(i) + std::string(" requested in an array of size ") +
boost::lexical_cast<std::string>(this->num_elements())));
return (get())[i];
}

Friends And Related Function Documentation

template<typename DataType >
friend class LinearSystem
friend

Definition at line 569 of file SharedArray.hpp.

template<typename DataType >
friend class NekMatrix
friend

Definition at line 567 of file SharedArray.hpp.

template<typename DataType >
friend class NekVector
friend

Definition at line 564 of file SharedArray.hpp.