#include <deal.II/base/subscriptor.h>
#include <deal.II/base/table_indices.h>
#include <deal.II/base/memory_consumption.h>
+#include <deal.II/base/aligned_vector.h>
#include <cstddef>
#include <algorithm>
typedef const T value_type;
typedef const TableBase<N,T> TableType;
- typedef typename std::vector<T>::const_iterator iterator;
- typedef typename std::vector<T>::const_iterator const_iterator;
+ typedef typename AlignedVector<T>::const_iterator iterator;
+ typedef typename AlignedVector<T>::const_iterator const_iterator;
- typedef typename std::vector<T>::const_reference reference;
- typedef typename std::vector<T>::const_reference const_reference;
+ typedef typename AlignedVector<T>::const_reference reference;
+ typedef typename AlignedVector<T>::const_reference const_reference;
};
/**
typedef T value_type;
typedef TableBase<N,T> TableType;
- typedef typename std::vector<T>::iterator iterator;
- typedef typename std::vector<T>::const_iterator const_iterator;
+ typedef typename AlignedVector<T>::iterator iterator;
+ typedef typename AlignedVector<T>::const_iterator const_iterator;
- typedef typename std::vector<T>::reference reference;
- typedef typename std::vector<T>::const_reference const_reference;
+ typedef typename AlignedVector<T>::reference reference;
+ typedef typename AlignedVector<T>::const_reference const_reference;
};
* Return a read-write reference
* to the indicated element.
*/
- typename std::vector<T>::reference
+ typename AlignedVector<T>::reference
operator () (const TableIndices<N> &indices);
/**
* don't know here whether
* copying is expensive or not.
*/
- typename std::vector<T>::const_reference
+ typename AlignedVector<T>::const_reference
operator () (const TableIndices<N> &indices) const;
/**
* used internally and in
* functions already checked.
*/
- typename std::vector<T>::reference el (const TableIndices<N> &indices);
+ typename AlignedVector<T>::reference el (const TableIndices<N> &indices);
/**
* Return the value of the
* don't know here whether
* copying is expensive or not.
*/
- typename std::vector<T>::const_reference el (const TableIndices<N> &indices) const;
+ typename AlignedVector<T>::const_reference el (const TableIndices<N> &indices) const;
/**
* @deprecated This function
* cast from const), otherwise,
* keep away!
*/
- typename std::vector<T>::const_pointer data () const DEAL_II_DEPRECATED;
+ typename AlignedVector<T>::const_pointer data () const DEAL_II_DEPRECATED;
protected:
/**
* Component-array.
*/
- std::vector<T> values;
+ AlignedVector<T> values;
/**
* Size in each direction of the
* data element. Returns a
* read-only reference.
*/
- typename std::vector<T>::const_reference
+ typename AlignedVector<T>::const_reference
operator [] (const unsigned int i) const;
/**
* data element. Returns a
* read-write reference.
*/
- typename std::vector<T>::reference
+ typename AlignedVector<T>::reference
operator [] (const unsigned int i);
/**
* data element. Returns a
* read-only reference.
*/
- typename std::vector<T>::const_reference
+ typename AlignedVector<T>::const_reference
operator () (const unsigned int i) const;
/**
* data element. Returns a
* read-write reference.
*/
- typename std::vector<T>::reference
+ typename AlignedVector<T>::reference
operator () (const unsigned int i);
/**
* base class available also in
* this class.
*/
- typename std::vector<T>::reference
+ typename AlignedVector<T>::reference
operator () (const TableIndices<1> &indices);
/**
* base class available also in
* this class.
*/
- typename std::vector<T>::const_reference
+ typename AlignedVector<T>::const_reference
operator () (const TableIndices<1> &indices) const;
};
* This version of the function
* only allows read access.
*/
- typename std::vector<T>::const_reference
+ typename AlignedVector<T>::const_reference
operator () (const unsigned int i,
const unsigned int j) const;
* This version of the function
* allows read-write access.
*/
- typename std::vector<T>::reference
+ typename AlignedVector<T>::reference
operator () (const unsigned int i,
const unsigned int j);
* base class available also in
* this class.
*/
- typename std::vector<T>::reference
+ typename AlignedVector<T>::reference
operator () (const TableIndices<2> &indices);
/**
* base class available also in
* this class.
*/
- typename std::vector<T>::const_reference
+ typename AlignedVector<T>::const_reference
operator () (const TableIndices<2> &indices) const;
* table classes for 2d arrays,
* then called <tt>vector2d</tt>.
*/
- typename std::vector<T>::reference el (const unsigned int i,
- const unsigned int j);
+ typename AlignedVector<T>::reference el (const unsigned int i,
+ const unsigned int j);
/**
* Return the value of the
* table classes for 2d arrays,
* then called <tt>vector2d</tt>.
*/
- typename std::vector<T>::const_reference el (const unsigned int i,
- const unsigned int j) const;
+ typename AlignedVector<T>::const_reference el (const unsigned int i,
+ const unsigned int j) const;
};
* This version of the function
* only allows read access.
*/
- typename std::vector<T>::const_reference operator () (const unsigned int i,
- const unsigned int j,
- const unsigned int k) const;
+ typename AlignedVector<T>::const_reference operator () (const unsigned int i,
+ const unsigned int j,
+ const unsigned int k) const;
/**
* This version of the function
* allows read-write access.
*/
- typename std::vector<T>::reference operator () (const unsigned int i,
- const unsigned int j,
- const unsigned int k);
+ typename AlignedVector<T>::reference operator () (const unsigned int i,
+ const unsigned int j,
+ const unsigned int k);
/**
* Make the corresponding
* base class available also in
* this class.
*/
- typename std::vector<T>::reference operator () (const TableIndices<3> &indices);
+ typename AlignedVector<T>::reference operator () (const TableIndices<3> &indices);
/**
* Make the corresponding
* base class available also in
* this class.
*/
- typename std::vector<T>::const_reference operator () (const TableIndices<3> &indices) const;
+ typename AlignedVector<T>::const_reference operator () (const TableIndices<3> &indices) const;
};
* This version of the function
* only allows read access.
*/
- typename std::vector<T>::const_reference operator () (const unsigned int i,
- const unsigned int j,
- const unsigned int k,
- const unsigned int l) const;
+ typename AlignedVector<T>::const_reference operator () (const unsigned int i,
+ const unsigned int j,
+ const unsigned int k,
+ const unsigned int l) const;
/**
* This version of the function
* allows read-write access.
*/
- typename std::vector<T>::reference operator () (const unsigned int i,
- const unsigned int j,
- const unsigned int k,
- const unsigned int l);
+ typename AlignedVector<T>::reference operator () (const unsigned int i,
+ const unsigned int j,
+ const unsigned int k,
+ const unsigned int l);
/**
* Make the corresponding
* base class available also in
* this class.
*/
- typename std::vector<T>::reference
+ typename AlignedVector<T>::reference
operator () (const TableIndices<4> &indices);
/**
* base class available also in
* this class.
*/
- typename std::vector<T>::const_reference
+ typename AlignedVector<T>::const_reference
operator () (const TableIndices<4> &indices) const;
};
* This version of the function
* only allows read access.
*/
- typename std::vector<T>::const_reference operator () (const unsigned int i,
- const unsigned int j,
- const unsigned int k,
- const unsigned int l,
- const unsigned int m) const;
+ typename AlignedVector<T>::const_reference operator () (const unsigned int i,
+ const unsigned int j,
+ const unsigned int k,
+ const unsigned int l,
+ const unsigned int m) const;
/**
* Direct access to one element
* This version of the function
* allows read-write access.
*/
- typename std::vector<T>::reference operator () (const unsigned int i,
- const unsigned int j,
- const unsigned int k,
- const unsigned int l,
- const unsigned int m);
+ typename AlignedVector<T>::reference operator () (const unsigned int i,
+ const unsigned int j,
+ const unsigned int k,
+ const unsigned int l,
+ const unsigned int m);
/**
* Make the corresponding
* base class available also in
* this class.
*/
- typename std::vector<T>::reference
+ typename AlignedVector<T>::reference
operator () (const TableIndices<5> &indices);
/**
* base class available also in
* this class.
*/
- typename std::vector<T>::const_reference
+ typename AlignedVector<T>::const_reference
operator () (const TableIndices<5> &indices) const;
};
* This version of the function
* only allows read access.
*/
- typename std::vector<T>::const_reference operator () (const unsigned int i,
- const unsigned int j,
- const unsigned int k,
- const unsigned int l,
- const unsigned int m,
- const unsigned int n) const;
+ typename AlignedVector<T>::const_reference operator () (const unsigned int i,
+ const unsigned int j,
+ const unsigned int k,
+ const unsigned int l,
+ const unsigned int m,
+ const unsigned int n) const;
/**
* Direct access to one element
* This version of the function
* allows read-write access.
*/
- typename std::vector<T>::reference operator () (const unsigned int i,
- const unsigned int j,
- const unsigned int k,
- const unsigned int l,
- const unsigned int m,
- const unsigned int n);
+ typename AlignedVector<T>::reference operator () (const unsigned int i,
+ const unsigned int j,
+ const unsigned int k,
+ const unsigned int l,
+ const unsigned int m,
+ const unsigned int n);
/**
* Make the corresponding
* base class available also in
* this class.
*/
- typename std::vector<T>::reference
+ typename AlignedVector<T>::reference
operator () (const TableIndices<6> &indices);
/**
* base class available also in
* this class.
*/
- typename std::vector<T>::const_reference
+ typename AlignedVector<T>::const_reference
operator () (const TableIndices<6> &indices) const;
};
* This version of the function
* only allows read access.
*/
- typename std::vector<T>::const_reference operator () (const unsigned int i,
- const unsigned int j,
- const unsigned int k,
- const unsigned int l,
- const unsigned int m,
- const unsigned int n,
- const unsigned int o) const;
+ typename AlignedVector<T>::const_reference operator () (const unsigned int i,
+ const unsigned int j,
+ const unsigned int k,
+ const unsigned int l,
+ const unsigned int m,
+ const unsigned int n,
+ const unsigned int o) const;
/**
* Direct access to one element
* This version of the function
* allows read-write access.
*/
- typename std::vector<T>::reference operator () (const unsigned int i,
- const unsigned int j,
- const unsigned int k,
- const unsigned int l,
- const unsigned int m,
- const unsigned int n,
- const unsigned int o);
+ typename AlignedVector<T>::reference operator () (const unsigned int i,
+ const unsigned int j,
+ const unsigned int k,
+ const unsigned int l,
+ const unsigned int m,
+ const unsigned int n,
+ const unsigned int o);
/**
* Make the corresponding
* base class available also in
* this class.
*/
- typename std::vector<T>::reference
+ typename AlignedVector<T>::reference
operator () (const TableIndices<7> &indices);
/**
* base class available also in
* this class.
*/
- typename std::vector<T>::const_reference
+ typename AlignedVector<T>::const_reference
operator () (const TableIndices<7> &indices) const;
};
* This version of the function
* only allows read access.
*/
- typename std::vector<T>::const_reference operator () (const unsigned int i,
- const unsigned int j) const;
+ typename AlignedVector<T>::const_reference operator () (const unsigned int i,
+ const unsigned int j) const;
/**
* Direct access to one element
* This version of the function
* allows read-write access.
*/
- typename std::vector<T>::reference operator () (const unsigned int i,
- const unsigned int j);
+ typename AlignedVector<T>::reference operator () (const unsigned int i,
+ const unsigned int j);
/**
* Number of rows. This function
* table classes for 2d arrays,
* then called <tt>vector2d</tt>.
*/
- typename std::vector<T>::reference el (const unsigned int i,
+ typename AlignedVector<T>::reference el (const unsigned int i,
const unsigned int j);
/**
* table classes for 2d arrays,
* then called <tt>vector2d</tt>.
*/
- typename std::vector<T>::const_reference el (const unsigned int i,
+ typename AlignedVector<T>::const_reference el (const unsigned int i,
const unsigned int j) const;
};
{
reinit (src.table_size);
if (src.n_elements() != 0)
- std::copy (src.values.begin(), src.values.end(), values.begin());
+ internal::AlignedVectorMove<T> (const_cast<T*>(src.values.begin()),
+ const_cast<T*>(src.values.end()),
+ values.begin(),
+ true);
}
{
reinit (m.size());
if (!empty())
- std::copy (m.values.begin(), m.values.end(), values.begin());
+ internal::AlignedVectorMove<T> (const_cast<T*>(m.values.begin()),
+ const_cast<T*>(m.values.end()),
+ values.begin(),
+ true);
return *this;
}
TableBase<N,T> &
TableBase<N,T>::operator = (const TableBase<N,T2> &m)
{
- reinit (m.size());
+ reinit (m.size(), true);
if (!empty())
std::copy (m.values.begin(), m.values.begin() + n_elements(),
values.begin());
void
TableBase<N,T>::reset_values ()
{
+ // use parallel set operation
if (n_elements() != 0)
- std::fill (values.begin(), values.end(), T());
+ internal::AlignedVectorSet<T> (values.size(), T(),
+ values.begin());
}
TableBase<N,T>::fill (const T &value)
{
if (n_elements() != 0)
- std::fill (values.begin(), values.end(), value);
+ internal::AlignedVectorSet<T> (values.size(), value,
+ values.begin());
}
const unsigned int new_size = n_elements();
- // if zero size was given: free all
- // memory
+ // if zero size was given: free all memory
if (new_size == 0)
{
values.resize (0);
return;
}
- // if new size is nonzero:
- // if necessary allocate
- // additional memory
- values.resize (new_size);
-
- // reinitialize contents of old or
- // new memory. note that we
- // actually need to do this here,
- // even in the case that we
- // reallocated memory, since per
- // C++ standard, clause 5.3.4/15
- // the newly allocated objects are
- // only default initialized by
- // operator new[] if they are
- // non-POD type. In other words, if
- // we have a table of doubles, then
- // their values after calling 'new
- // double[val_size]' is
- // indetermined.
- if (fast == false)
- reset_values ();
+ // if new size is nonzero: if necessary allocate additional memory, and if
+ // not fast resize, zero out all values)
+ values.resize_fast (new_size);
+ if (!fast)
+ internal::AlignedVectorSet<T> (values.size(), T(),
+ values.begin());
}
ExcMessage("Trying to fill an empty matrix."));
if (C_style_indexing)
- for (typename std::vector<T>::iterator p = values.begin();
+ for (typename AlignedVector<T>::iterator p = values.begin();
p != values.end(); ++p)
*p = *entries++;
else
template <int N, typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
TableBase<N,T>::operator () (const TableIndices<N> &indices) const
{
for (unsigned int n=0; n<N; ++n)
template <int N, typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
TableBase<N,T>::operator () (const TableIndices<N> &indices)
{
for (unsigned int n=0; n<N; ++n)
template <int N, typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
TableBase<N,T>::el (const TableIndices<N> &indices) const
{
return values[position(indices)];
template <int N, typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
TableBase<N,T>::el (const TableIndices<N> &indices)
{
Assert (position(indices) < values.size(),
template <int N, typename T>
inline
-typename std::vector<T>::const_pointer
+typename AlignedVector<T>::const_pointer
TableBase<N,T>::data () const
{
if (values.size() == 0)
- return typename std::vector<T>::const_pointer();
+ return typename AlignedVector<T>::const_pointer();
else
return &values[0];
}
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<1,T>::operator [] (const unsigned int i) const
{
Assert (i < this->table_size[0],
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<1,T>::operator [] (const unsigned int i)
{
Assert (i < this->table_size[0],
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<1,T>::operator () (const unsigned int i) const
{
Assert (i < this->table_size[0],
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<1,T>::operator () (const unsigned int i)
{
Assert (i < this->table_size[0],
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<1,T>::operator () (const TableIndices<1> &indices) const
{
return TableBase<1,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<1,T>::operator () (const TableIndices<1> &indices)
{
return TableBase<1,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<2,T>::operator () (const unsigned int i,
const unsigned int j) const
{
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<2,T>::operator () (const unsigned int i,
const unsigned int j)
{
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<2,T>::operator () (const TableIndices<2> &indices) const
{
return TableBase<2,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<2,T>::operator () (const TableIndices<2> &indices)
{
return TableBase<2,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<2,T>::el (const unsigned int i,
const unsigned int j) const
{
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<2,T>::el (const unsigned int i,
const unsigned int j)
{
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
TransposeTable<T>::operator () (const unsigned int i,
const unsigned int j) const
{
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
TransposeTable<T>::operator () (const unsigned int i,
const unsigned int j)
{
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
TransposeTable<T>::el (const unsigned int i,
const unsigned int j) const
{
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
TransposeTable<T>::el (const unsigned int i,
const unsigned int j)
{
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<3,T>::operator () (const unsigned int i,
const unsigned int j,
const unsigned int k) const
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<3,T>::operator () (const unsigned int i,
const unsigned int j,
const unsigned int k)
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<3,T>::operator () (const TableIndices<3> &indices) const
{
return TableBase<3,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<3,T>::operator () (const TableIndices<3> &indices)
{
return TableBase<3,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<4,T>::operator () (const unsigned int i,
const unsigned int j,
const unsigned int k,
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<4,T>::operator () (const unsigned int i,
const unsigned int j,
const unsigned int k,
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<4,T>::operator () (const TableIndices<4> &indices) const
{
return TableBase<4,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<4,T>::operator () (const TableIndices<4> &indices)
{
return TableBase<4,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<5,T>::operator () (const unsigned int i,
const unsigned int j,
const unsigned int k,
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<5,T>::operator () (const unsigned int i,
const unsigned int j,
const unsigned int k,
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<5,T>::operator () (const TableIndices<5> &indices) const
{
return TableBase<5,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<5,T>::operator () (const TableIndices<5> &indices)
{
return TableBase<5,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<6,T>::operator () (const unsigned int i,
const unsigned int j,
const unsigned int k,
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<6,T>::operator () (const unsigned int i,
const unsigned int j,
const unsigned int k,
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<6,T>::operator () (const TableIndices<6> &indices) const
{
return TableBase<6,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<6,T>::operator () (const TableIndices<6> &indices)
{
return TableBase<6,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<7,T>::operator () (const unsigned int i,
const unsigned int j,
const unsigned int k,
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<7,T>::operator () (const unsigned int i,
const unsigned int j,
const unsigned int k,
template <typename T>
inline
-typename std::vector<T>::const_reference
+typename AlignedVector<T>::const_reference
Table<7,T>::operator () (const TableIndices<7> &indices) const
{
return TableBase<7,T>::operator () (indices);
template <typename T>
inline
-typename std::vector<T>::reference
+typename AlignedVector<T>::reference
Table<7,T>::operator () (const TableIndices<7> &indices)
{
return TableBase<7,T>::operator () (indices);