Skip to content
Snippets Groups Projects
Commit 3717983a authored by Simon Praetorius's avatar Simon Praetorius
Browse files

Extend the DenseVectorSpan test and deduction guides

parent 1424ecfe
Branches feature/densevectorview
No related tags found
1 merge request!1354Draft: Add a view to raw vector data with `DenseVector` interface
Pipeline #75613 waiting for manual action
......@@ -70,6 +70,10 @@ template <class K>
DenseVectorSpan (K*, std::size_t)
-> DenseVectorSpan<K>;
template <class K, std::size_t N>
DenseVectorSpan (K (&)[N])
-> DenseVectorSpan<K,N>;
template <class S, std::enable_if_t<Dune::IsNumber<S>::value,int> = 0>
DenseVectorSpan (S&)
-> DenseVectorSpan<S,1>;
......
......@@ -24,13 +24,26 @@ int main()
std::vector<double> x(3);
std::array<double,3> y{1.0,2.0,3.0};
auto x_span = Dune::DenseVectorSpan(x);
auto y_span = Dune::DenseVectorSpan(y);
{
auto x_span = Dune::DenseVectorSpan(x);
auto y_span = Dune::DenseVectorSpan(y);
matrix.mv(y_span,x_span);
test.check(x[0] == -3.0);
test.check(x[1] == 2.0);
test.check(x[2] == 9.0);
}
matrix.mv(y_span,x_span);
test.check(x[0] == -3.0);
test.check(x[1] == 2.0);
test.check(x[2] == 9.0);
{
[[maybe_unused]] auto x_span1 = Dune::DenseVectorSpan(x.data(), x.size());
[[maybe_unused]] auto x_span2 = Dune::DenseVectorSpan<double,3>(x.data());
}
{
double data[3]{1.0,2.0,3.0};
[[maybe_unused]] auto x_span1 = Dune::DenseVectorSpan(data, 3);
[[maybe_unused]] auto x_span2 = Dune::DenseVectorSpan(data);
}
return test.exit();
}
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