#define __deal2__vector2d_h
#include <base/subscriptor.h>
-#include <vector>
+
/**
* Two-dimensional array of arbitrary data.
* standard C++ classes. This, although array would have been
* preferrable, since a vector should be element of a vector space.
*
- * @author Guido Kanschat, 2001
+ * @author Guido Kanschat, 2001. Parts by Wolfgang Bangerth and others.
*/
template<typename T>
class vector2d : public Subscriptor
{
public:
- /**
- * Constructor for a quadratic
- * @p{rows} by @p{rows} array. The
- * standard constructor creates an
- * empty object.
- */
- vector2d (const unsigned int rows = 0);
-
- /**
- * Constructor for a @p{rows} by
- * @p{cols} array.
- */
- vector2d (const unsigned int rows,
- const unsigned int cols);
-
- /**
- * Copy-constructor for deep copy.
- */
- vector2d (const vector2d&);
+ /**
+ * Constructor for a quadratic
+ * @p{rows} by @p{rows} array. The
+ * standard constructor creates an
+ * empty object.
+ */
+ vector2d (const unsigned int rows = 0);
+
+ /**
+ * Constructor for a @p{rows} by
+ * @p{cols} array.
+ */
+ vector2d (const unsigned int rows,
+ const unsigned int cols);
+
+ /**
+ * Copy-constructor for deep copy.
+ */
+ vector2d (const vector2d&);
/**
* Constructor initializing from
* an array of data elements. The array
* is arranged line by line. No
* range checking is performed.
*/
- vector2d (const unsigned int rows,
- const unsigned int cols,
- const T* entries);
-
- /**
- * Assignment operator.
- * Copy all elements of @p{src}
- * into the matrix. The size is
- * adjusted if needed.
- *
- * We can't use the other, templatized
- * version since if we don't declare
- * this one, the compiler will happily
- * generate a predefined copy
- * operator which is not what we want.
- */
+ vector2d (const unsigned int rows,
+ const unsigned int cols,
+ const T* entries);
+
+ /**
+ * Assignment operator.
+ * Copy all elements of @p{src}
+ * into the matrix. The size is
+ * adjusted if needed.
+ *
+ * We can't use the other, templatized
+ * version since if we don't declare
+ * this one, the compiler will happily
+ * generate a predefined copy
+ * operator which is not what we want.
+ */
vector2d<T>& operator = (const vector2d<T>& src);
-
- /**
- * Destructor. Free allocated memory.
- */
- ~vector2d ();
-
- /**
- * Assignment operator.
- * Copy all elements of @p{src}
- * into the array. The size is
- * adjusted if needed.
- *
- * This function requires that the
- * type @p{T2} is convertible to
- * @p{T}.
- */
- template<typename T2>
- vector2d<T>& operator = (const vector2d<T2>& src);
-
- /**
- * Set dimension to $m\times n$ and
- * allocate memory if necessary. Forget
- * the previous content of the array.
- */
+
+ /**
+ * Destructor. Free allocated memory.
+ */
+ ~vector2d ();
+
+ /**
+ * Assignment operator.
+ * Copy all elements of @p{src}
+ * into the array. The size is
+ * adjusted if needed.
+ *
+ * This function requires that the
+ * type @p{T2} is convertible to
+ * @p{T}.
+ */
+ template<typename T2>
+ vector2d<T>& operator = (const vector2d<T2> &src);
+
+ /**
+ * Set dimension to $m\times n$
+ * and allocate memory if
+ * necessary. Forget the previous
+ * content of the array.
+ */
void reinit (const unsigned int m,
const unsigned int n);
/**
- * Set dimension to $n\times n$ and
- * allocate memory if necessary. Forget
- * the previous content of the array.
+ * Set dimension to $n\times n$
+ * and allocate memory if
+ * necessary. Forget the previous
+ * content of the array.
*/
void reinit (const unsigned int n);
* array will be zero.
*/
template <class T2>
- void reinit (const vector2d<T2>&);
+ void reinit (const vector2d<T2> &shape);
/**
* Number of rows.
void clear ();
/**
- * Fill array with an array of elements.
- * The array is arranged line by line. No
+ * Fill array with an array of
+ * elements. The array is
+ * arranged line by line. No
* range checking is performed.
*/
template<typename T2>
- void fill (const T2* entries);
+ void fill (const T2 *entries);
/**
* Determine an estimate for the
unsigned int memory_consumption () const;
protected:
- /**
- * Return a read-write reference to the
- * element @p{(i,j)}.
- *
- * This function does no bounds
- * checking and is only to be used
- * internally and in functions
- * already checked.
- */
- T & el (const unsigned int i, const unsigned int j);
+ /**
+ * Return a read-write reference
+ * to the element @p{(i,j)}.
+ *
+ * This function does no bounds
+ * checking and is only to be
+ * used internally and in
+ * functions already checked.
+ */
+ T & el (const unsigned int i, const unsigned int j);
- /**
- * Return the value of the element @p{(i,j)}.
- *
- * This function does no bounds checking
- * and is only to be used
- * internally and in functions
- * already checked.
- */
- T el (const unsigned int i, const unsigned int j) const;
+ /**
+ * Return the value of the
+ * element @p{(i,j)}.
+ *
+ * This function does no bounds
+ * checking and is only to be
+ * used internally and in
+ * functions already checked.
+ */
+ T el (const unsigned int i, const unsigned int j) const;
/**
* Direct read-only access to
* Component-array.
*/
T* val;
+
/**
- * Size of array.
+ * Size of array. This may be
+ * larger than the number of
+ * actually used elements, since
+ * we don't shrink the array upon
+ * calls to @p{reinit} unless the
+ * new size is zero.
*/
unsigned int val_size;
};
+/* --------------------- Template and inline functions ---------------- */
+
template <typename T>
inline
vector2d<T>::~vector2d ()
};
+
template <typename T>
inline
void
};
+
template <typename T>
template <typename T2>
inline
}
+
template <typename T>
void
vector2d<T>::reinit (const unsigned int mm,
};
+
template <typename T>
void
vector2d<T>::reinit (const unsigned int n)
};
+
template <typename T>
template <typename T2>
void
};
+
template <typename T>
vector2d<T>::vector2d (const unsigned int m,
const unsigned int n) :
};
+
template <typename T>
vector2d<T>::vector2d (const unsigned int m) :
val (0),
};
+
template <typename T>
vector2d<T>::vector2d (const vector2d &m) :
Subscriptor (),
};
+
template <typename T>
vector2d<T>&
vector2d<T>::operator = (const vector2d<T>& m)
}
+
template <typename T>
template <typename T2>
vector2d<T>&
}
+
template <class T>
inline
unsigned int
}
+
template <class T>
inline
unsigned int
}
+
+
template <typename T>
inline T &
vector2d<T>::el (const unsigned int i, const unsigned int j)
};
+
template <typename T>
inline T
vector2d<T>::operator() (const unsigned int i, const unsigned int j) const
};
+
template <typename T>
inline
const T *
}
+
template <typename T>
inline
unsigned int