Is there a function similar to numpy copy for copying views? If not, what is the simplest way to deep copy complex views? The copy constructor still points to the same internal values, which is fine most of the times, but there are times when a deep copy is needed.
Asked
Active
Viewed 837 times
4
-
What do you mean with complex views? A view of a view? Shouldn't a copy of a view always be the same, not depending on if it is a copy of the first or the tenth view, since it is creating a new object anyways? If I am wrong, I am thankful for an explanation. – JE_Muc Jul 06 '18 at 12:41
-
1More like a view of a view of a strided view of a view. And the problem is that all of those, and any of their assignment ponts to the same underlying elements. So if i need to modify all beforehand will change. Which would be fine if the xtensor had a copy function like numpy, but i have not found it yet. – Hajdu Gábor Jul 06 '18 at 12:46
1 Answers
4
You can simply assign the view to an xarray or an xtensor object if you know its number of dimensions:
xt::xarray<double> cmy_copy(view);

johan mabille
- 414
- 2
- 4