@@ -48,6 +48,7 @@ namespace x
4848 xt::xstrided_slice_vector _lslice;
4949 std::shared_ptr<xt::xarray<T>> _xarray;
5050 mutable T _replica = 0 ;
51+ bool _issliced = false ;
5152
5253 public:
5354 using typed_ptr_type = std::shared_ptr<DPTensorX<T>>;
@@ -56,7 +57,22 @@ namespace x
5657 DPTensorX (PVSlice && slc, I && ax, rank_type owner=NOOWNER)
5758 : _owner(owner),
5859 _slice (std::move(slc)),
59- _lslice(to_xt(_slice.local_slice_of_rank())),
60+ _xarray(std::make_shared<xt::xarray<T>>(std::forward<I>(ax)))
61+ {
62+ }
63+
64+ template <typename I>
65+ DPTensorX (const shape_type & slc, I && ax, rank_type owner=NOOWNER)
66+ : _owner(owner),
67+ _slice(slc),
68+ _xarray(std::make_shared<xt::xarray<T>>(std::forward<I>(ax)))
69+ {
70+ }
71+
72+ template <typename I>
73+ DPTensorX (shape_type && slc, I && ax, rank_type owner=NOOWNER)
74+ : _owner(owner),
75+ _slice(std::move(slc)),
6076 _xarray(std::make_shared<xt::xarray<T>>(std::forward<I>(ax)))
6177 {
6278 }
@@ -66,7 +82,8 @@ namespace x
6682 : _owner(owner),
6783 _slice(org._slice, slc),
6884 _lslice(to_xt(_slice.local_slice_of_rank())),
69- _xarray(org._xarray)
85+ _xarray(org._xarray),
86+ _issliced(true )
7087 {
7188 if (owner == NOOWNER && slice ().size () <= 1 ) {
7289 set_owner (org.slice ().owner (slc));
@@ -80,21 +97,27 @@ namespace x
8097 : _owner(theTransceiver->rank ()),
8198 _slice(std::forward<PVSlice>(slc)),
8299 _lslice(to_xt(_slice.slice())),
83- _xarray()
100+ _xarray(),
101+ _issliced(true )
84102 {
85103 _xarray = org;
86104 }
87105
88106 DPTensorX (const T & v)
89107 : _owner(theTransceiver->rank ()),
90108 _slice(shape_type{1 }),
91- _lslice({xt::newaxis ()}), // to_xt(_slice.slice())),
109+ // _lslice({xt::newaxis()}), //to_xt(_slice.slice())),
92110 _xarray(std::make_shared<xt::xarray<T>>(1 )),
93111 _replica(v)
94112 {
95113 *_xarray = v;
96114 }
97115
116+ bool is_sliced () const
117+ {
118+ return _issliced;
119+ }
120+
98121 virtual std::string __repr__ () const
99122 {
100123 auto v = xt::strided_view (xarray (), lslice ());
0 commit comments