Assignment from TensorMap
wrapping a const
type
#94
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is more of a bug report/feature request than a real pull request, since I'm certain the solution (and possibly the problem description) here is incomplete at best. The additional unit test shows the situation :
Prior to this patch, the above will not compile. That is, we cannot assign a
TensorMap
wrapping an array ofconst
qualified elements to aTensor
containing non-const
elements.For background, I came across this issue when wanting to copy the (3-dimensional) positions of the 4 nodes in a tetrahedron into a 4x3 tensor. Those node positions are passed as
const
-qualified (non-Fastor) vectors, which I attempted toTensorMap
then assign each in turn to a slice of myTensor
. But of course that didn't work.This pull request does the very minimum to get the above situation working. I'm happy for you to take it over or replace it, or I can do minor tweaks as requested. I started using Fastor only a couple of days ago, so I'm probably not the best person to be fiddling ;)
A brief summary of changes:
const
) to constructSIMDVector
ineval
functions, otherwise we get "assignment of read-only location" errors.const
-qualify destination tensor inassign
, otherwise overload resolution of calledtrivial_assign
fails.maskstore
overload causing "multiple definition ofFastor::maskstore
" errors (this is unrelated to the issue of assigningconst
data, but caused compilation errors for me - should probably be a separate PR/issue).