* those in the @p{C++} standard libraries
* @p{vector<...>} class.
*/
- typedef Number value_type;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef value_type* iterator;
- typedef const value_type* const_iterator;
- typedef value_type& reference;
- typedef const value_type& const_reference;
- typedef size_t size_type;
+ typedef Number value_type;
+ typedef value_type *pointer;
+ typedef const value_type *const_pointer;
+ typedef value_type *iterator;
+ typedef const value_type *const_iterator;
+ typedef value_type &reference;
+ typedef const value_type &const_reference;
+ typedef size_t size_type;
/**
* initialize all elements with zero.
*/
Vector (const unsigned int n);
+
+ /**
+ * Initialize the vector with a
+ * given range of values pointed
+ * to by the iterators. This
+ * function is there in analogy
+ * to the @p{std::vector} class.
+ */
+ template <typename InputIterator>
+ Vector (const InputIterator first, const InputIterator last);
/**
* Destructor, deallocates
{}
+
+template <typename Number>
+template <typename InputIterator>
+Vector<Number>::Vector (const InputIterator first, const InputIterator last)
+ :
+ dim (0),
+ maxdim (0),
+ val (0)
+{
+ // allocate memory. do not
+ // initialize it, as we will copy
+ // over to it in a second
+ reinit (std::distance (first, last), true);
+ std::copy (first, last, begin());
+};
+
+
+
template <typename Number>
inline
Vector<Number>::Vector (const unsigned int n) :
template <typename Number>
inline
-void Vector<Number>::reinit (const unsigned int n, const bool fast) {
+void Vector<Number>::reinit (const unsigned int n, const bool fast)
+{
if (n==0)
{
if (val) delete[] val;
// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
d1 = 2.5;
print (d1);
+
+ // initialize with iterators
+ number1 array[] = { 0.0, 1.1, 2.2, 3.3 };
+ Vector<number1> d4 (&array[0], &array[4]);
+ print (d4);
deallog << "Extract number" << std::endl;
// Each line should contain two equal numbers
DEAL::0.00 2.00 8.00 18.00 32.00 50.00 72.00 98.00 128.00 162.00
DEAL::0.00 2.00 4.00 6.00 8.00 10.00 12.00 14.00 16.00 18.00
DEAL::2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50
+DEAL::0.00 1.10 2.20 3.30
DEAL::Extract number
DEAL::-105.00 -105.00
DEAL::1140.00 1140.00
DEAL::0.00 2.00 8.00 18.00 32.00 50.00 72.00 98.00 128.00 162.00
DEAL::0.00 2.00 4.00 6.00 8.00 10.00 12.00 14.00 16.00 18.00
DEAL::2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50
+DEAL::0.00 1.10 2.20 3.30
DEAL::Extract number
DEAL::-105.00 -105.00
DEAL::1140.00 1140.00
DEAL::0.00 2.00 8.00 18.00 32.00 50.00 72.00 98.00 128.00 162.00
DEAL::0.00 2.00 4.00 6.00 8.00 10.00 12.00 14.00 16.00 18.00
DEAL::2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50
+DEAL::0.00 1.10 2.20 3.30
DEAL::Extract number
DEAL::-105.00 -105.00
DEAL::1140.00 1140.00