Skip to content
Snippets Groups Projects
Commit 06a10d44 authored by Andreas Dedner's avatar Andreas Dedner
Browse files
parents 586174c1 bd498e0d
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@
#include <cmath>
#include <cstddef>
#include <iostream>
#include <algorithm>
#include <initializer_list>
#include <dune/common/exceptions.hh>
......@@ -100,21 +101,19 @@ namespace Dune
*/
FieldMatrix (std::initializer_list<std::initializer_list<K> > const &ll)
{
assert(ll.size() == rows);
size_t i = 0;
for (typename std::initializer_list<std::initializer_list<K> >::
const_iterator lit = ll.begin(); lit != ll.end(); ++lit)
_data[i++] = *lit;
assert(ll.size() == rows); // Actually, this is not needed any more!
std::copy_n(ll.begin(), std::min(static_cast<std::size_t>(ROWS),
ll.size()),
_data.begin());
}
/** \brief Constructor initializing the matrix from a list of vector
*/
FieldMatrix(std::initializer_list<Dune::FieldVector<K, cols> > const &l) {
assert(l.size() == rows);
size_t i = 0;
for (typename std::initializer_list<Dune::FieldVector<K, cols> >::
const_iterator lit = l.begin(); lit != l.end(); ++lit)
_data[i++] = *lit;
assert(l.size() == rows); // Actually, this is not needed any more!
std::copy_n(l.begin(), std::min(static_cast<std::size_t>(ROWS),
l.size()),
_data.begin());
}
//===== assignment
......
......@@ -11,6 +11,7 @@
#include <cstring>
#include <utility>
#include <initializer_list>
#include <algorithm>
#include <dune/common/std/constexpr.hh>
......@@ -119,11 +120,10 @@ namespace Dune {
FieldVector (std::initializer_list<K> const &l)
{
assert(l.size() == dimension);
size_t i = 0;
for (typename std::initializer_list<K>::const_iterator it = l.begin();
it != l.end(); ++it)
_data[i++] = *it;
assert(l.size() == dimension);// Actually, this is not needed any more!
std::copy_n(l.begin(), std::min(static_cast<std::size_t>(dimension),
l.size()),
_data.begin());
}
/**
......@@ -142,9 +142,8 @@ namespace Dune {
{
DUNE_UNUSED_PARAMETER(dummy);
// do a run-time size check, for the case that x is not a FieldVector
assert(x.size() == SIZE);
for (size_type i = 0; i<SIZE; i++)
_data[i] = x[i];
assert(x.size() == SIZE); // Actually this is not needed any more!
std::copy_n(x.begin(), std::min(static_cast<std::size_t>(SIZE),x.size()), _data.begin());
}
//! Constructor making vector with identical coordinates
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment