Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Public Types | Public Member Functions | Private Attributes | List of all members
AlignedVector< T > Class Template Reference

#include <vectorization.h>

Inheritance diagram for AlignedVector< T >:
[legend]

Public Types

typedef T value_type
 
typedef value_typepointer
 
typedef const value_typeconst_pointer
 
typedef value_typeiterator
 
typedef const value_typeconst_iterator
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef std::size_t size_type
 

Public Member Functions

 AlignedVector ()
 
 AlignedVector (const size_type size)
 
 ~AlignedVector ()
 
 AlignedVector (const AlignedVector< T > &vec)
 
AlignedVectoroperator= (const AlignedVector< T > &vec)
 
void resize_fast (const size_type size)
 
void resize (const size_type size_in, const T &init=T())
 
void reserve (const size_type size_alloc)
 
void clear ()
 
void push_back (const T in_data)
 
reference back ()
 
const_reference back () const
 
template<typename ForwardIterator >
void insert_back (ForwardIterator begin, ForwardIterator end)
 
void swap (AlignedVector< T > &vec)
 
size_type size () const
 
size_type capacity () const
 
reference operator[] (const size_type index)
 
const_reference operator[] (const size_type index) const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
size_type memory_consumption () const
 

Private Attributes

T * _data
 
T * _end_data
 
T * _end_allocated
 

Detailed Description

template<class T>
class AlignedVector< T >

This is a replacement class for std::vector to be used in combination with VectorizedArray and derived data types. It allocates memory aligned to addresses of a vectorized data type (for SSE, this is necessary in order to avoid segfaults, and for AVX it considerably increases performance). This could also be achieved by proving std::vector with a user-defined allocator. On the other hand, writing an own small vector class lets us insert assertions more easily, and cut some unnecessary functionality. Note that this vector is a bit more memory-consuming than std::vector because of alignment, so it is recommended to only use this vector on long vectors.

author Katharina Kormann, Martin Kronbichler, 2011

Definition at line 1563 of file vectorization.h.

Member Typedef Documentation

template<class T>
typedef T AlignedVector< T >::value_type

Declare standard types used in all containers. These types parallel those in the C++ standard libraries vector<...> class.

Definition at line 1572 of file vectorization.h.

Constructor & Destructor Documentation

template<class T>
AlignedVector< T >::AlignedVector ( )
inline

Empty constructor. Sets the vector size to zero.

Definition at line 1585 of file vectorization.h.

template<class T>
AlignedVector< T >::AlignedVector ( const size_type  size)
inline

Sets the vector size to the given size and initializes all elements with T().

Definition at line 1596 of file vectorization.h.

template<class T>
AlignedVector< T >::~AlignedVector ( )
inline

Destructor.

Definition at line 1609 of file vectorization.h.

template<class T>
AlignedVector< T >::AlignedVector ( const AlignedVector< T > &  vec)
inline

Copy constructor.

Definition at line 1617 of file vectorization.h.

Member Function Documentation

template<class T>
AlignedVector& AlignedVector< T >::operator= ( const AlignedVector< T > &  vec)
inline

Assignment to the input vector vec.

Definition at line 1632 of file vectorization.h.

template<class T>
void AlignedVector< T >::resize_fast ( const size_type  size)
inline

Change the size of the vector. It keeps old elements previously available but does not initialize the newly allocated memory, leaving it in an undefined state.

Definition at line 1646 of file vectorization.h.

template<class T>
void AlignedVector< T >::resize ( const size_type  size_in,
const T &  init = T() 
)
inline

Change the size of the vector. It keeps old elements previously available, and initializes each element with the specified data. If the new vector size is shorter than the old one, the memory is not released unless the new size is zero.

Definition at line 1660 of file vectorization.h.

template<class T>
void AlignedVector< T >::reserve ( const size_type  size_alloc)
inline

Reserve memory space for size elements. If the argument size is set to zero, all previously allocated memory is released.

In order to avoid too frequent reallocation (which involves copy of the data), this function doubles the amount of memory occupied when the given size is larger than the previously allocated size.

Definition at line 1691 of file vectorization.h.

template<class T>
void AlignedVector< T >::clear ( )
inline

Releases all previously allocated memory and leaves the vector in a state equivalent to the state after the default constructor has been called.

Definition at line 1748 of file vectorization.h.

template<class T>
void AlignedVector< T >::push_back ( const T  in_data)
inline

Inserts an element at the end of the vector, increasing the vector size by one. Note that the allocated size will double whenever the previous space is not enough to hold the new element.

Definition at line 1774 of file vectorization.h.

template<class T>
reference AlignedVector< T >::back ( )
inline

Returns the last element of the vector (read and write access).

Definition at line 1788 of file vectorization.h.

template<class T>
const_reference AlignedVector< T >::back ( ) const
inline

Returns the last element of the vector (read-only access).

Definition at line 1799 of file vectorization.h.

template<class T>
template<typename ForwardIterator >
void AlignedVector< T >::insert_back ( ForwardIterator  begin,
ForwardIterator  end 
)
inline

Inserts several elements at the end of the vector given by a range of elements.

Definition at line 1811 of file vectorization.h.

template<class T>
void AlignedVector< T >::swap ( AlignedVector< T > &  vec)
inline

Swaps the given vector with the calling vector.

Definition at line 1828 of file vectorization.h.

template<class T>
size_type AlignedVector< T >::size ( ) const
inline

Returns the size of the vector.

Definition at line 1838 of file vectorization.h.

template<class T>
size_type AlignedVector< T >::capacity ( ) const
inline

Returns the capacity of the vector, i.e., the size this vector can hold without reallocation. Note that capacity() >= size().

Definition at line 1849 of file vectorization.h.

template<class T>
reference AlignedVector< T >::operator[] ( const size_type  index)
inline

Read-write access to entry index in the vector.

Definition at line 1859 of file vectorization.h.

template<class T>
const_reference AlignedVector< T >::operator[] ( const size_type  index) const
inline

Read-only access to entry index in the vector.

Definition at line 1869 of file vectorization.h.

template<class T>
iterator AlignedVector< T >::begin ( )
inline

Returns a read and write pointer to the beginning of the data array.

Definition at line 1879 of file vectorization.h.

template<class T>
iterator AlignedVector< T >::end ( )
inline

Returns a read and write pointer to the end of the data array.

Definition at line 1888 of file vectorization.h.

template<class T>
const_iterator AlignedVector< T >::begin ( ) const
inline

Returns a read-only pointer to the beginning of the data array.

Definition at line 1897 of file vectorization.h.

template<class T>
const_iterator AlignedVector< T >::end ( ) const
inline

Returns a read-only pointer to the end of the data array.

Definition at line 1906 of file vectorization.h.

template<class T>
size_type AlignedVector< T >::memory_consumption ( ) const
inline

Returns the memory consumption of the allocated memory in this class. If the underlying type T allocates memory by itself, this memory is not counted.

Definition at line 1917 of file vectorization.h.

Member Data Documentation

template<class T>
T* AlignedVector< T >::_data
private

Pointer to actual class data.

Definition at line 1929 of file vectorization.h.

template<class T>
T* AlignedVector< T >::_end_data
private

Pointer to the end of valid data fields.

Definition at line 1934 of file vectorization.h.

template<class T>
T* AlignedVector< T >::_end_allocated
private

Pointer to the end of the allocated memory.

Definition at line 1939 of file vectorization.h.


The documentation for this class was generated from the following file: