New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement StridedArrayView #15972
Implement StridedArrayView #15972
Conversation
include/deal.II/base/array_view.h
Outdated
* This is particularly useful when you want to access only one lane of a | ||
* VectorizedArray. | ||
*/ | ||
template <typename ElementType, int stride = 1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template <typename ElementType, int stride = 1> | |
template <typename ElementType, std::size_t stride = 1> |
include/deal.II/base/array_view.h
Outdated
StridedArrayView(value_type *starting_element, const std::size_t n_elements) | ||
{ | ||
this->starting_element = starting_element; | ||
this->n_elements = n_elements; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the definition out of line of the class declaration?
Also, please use the initializer list feature:
StridedArrayView(value_type *starting_element, const std::size_t n_elements) | |
{ | |
this->starting_element = starting_element; | |
this->n_elements = n_elements; | |
} | |
StridedArrayView(value_type *starting_element, const std::size_t n_elements) | |
: starting_element (starting_element) | |
, n_elements (n_elements) | |
{} |
include/deal.II/base/array_view.h
Outdated
std::size_t | ||
size() const | ||
{ | ||
return this->n_elements; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the definition out of line. Same for the functions below.
f4fe6af
to
3d9fd71
Compare
@bangerth Updated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this separation makes sense. I will not approve because I was involved in discussions. One thing I will mention is that we discussed that it is good to provide the pointer iterators begin
and end
only for the actual ArrayView
class, because for a strided class one would need non-standard iterators, which is probably beyond the scope for a simple class like ArrayView
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if it is a good idea to make StridedArrayView
a base class of ArrayView
. StridedArrayView
looks like a variant of a view; there are other views like in the case of slices of python.
I know why you want to do this. You want to simply extract the strides in FPE.
Personally, I would prefer to have StridedArrayView
and ArrayView
and accept both classes in FPE and decide internally via const expressions what kind of strides to use. This is just a bit more code in FPE.
This would of course also be possible but I think |
3d9fd71
to
3f31534
Compare
This is one point of view. The other one is a filtered vector, where all entries are "enabled". |
Can we come to a decision here? I would like to move forward with #15971 |
I do not see an immediate use, but one could imagine several potential uses in some parts (e.g. for tensor-product evaluation). But I think someone else should decide. |
It seems there are no statements in support. Thus I suggest to solve the problem within |
What about adding it as a parallel class (and not as base class of Base class makes more sense for me because of the code duplication with this solution but this would also work. |
I don't have a particularly strong opinion about this patch, but would like to point out that we document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks ok for the present application.
/rebuild |
Let's merge so that @bergbauer can proceed with #15971. |
Needed for #15971