@@ -81,6 +81,20 @@ namespace xt
8181 using temporary_type = pytensor<T, N>;
8282 };
8383
84+ /* *
85+ * @class pytensor
86+ * @brief Multidimensional container providing the xtensor container semantics wrapping a numpy array.
87+ *
88+ * pytensor is similar to the xtensor container in that it has a static dimensionality.
89+ *
90+ * Unlike with the pyarray container, pytensor cannot be reshaped with a different number of dimensions
91+ * and reshapes are not reflected on the Python side. However, pytensor has benefits compared to pyarray
92+ * in terms of performances. pytensor shapes are stack-allocated which makes iteration upon pytensor
93+ * faster than with pyarray.
94+ *
95+ * @tparam T The type of the element stored in the pyarray.
96+ * @sa pyarray
97+ */
8498 template <class T , std::size_t N>
8599 class pytensor : public pycontainer <pytensor<T, N>>,
86100 public xcontainer_semantic<pytensor<T, N>>
@@ -158,6 +172,13 @@ namespace xt
158172 * pytensor implementation *
159173 ***************************/
160174
175+ /* *
176+ * @name Constructors
177+ */
178+ // @{
179+ /* *
180+ * Allocates an uninitialized pytensor that holds 1 element.
181+ */
161182 template <class T , std::size_t N>
162183 inline pytensor<T, N>::pytensor()
163184 {
@@ -167,6 +188,9 @@ namespace xt
167188 m_data[0 ] = T ();
168189 }
169190
191+ /* *
192+ * Allocates a pytensor with a nested initializer list.
193+ */
170194 template <class T , std::size_t N>
171195 inline pytensor<T, N>::pytensor(nested_initializer_list_t <T, N> t)
172196 {
@@ -195,13 +219,26 @@ namespace xt
195219 init_from_python ();
196220 }
197221
222+ /* *
223+ * Allocates an uninitialized pytensor with the specified shape and
224+ * layout.
225+ * @param shape the shape of the pytensor
226+ * @param l the layout of the pytensor
227+ */
198228 template <class T , std::size_t N>
199229 inline pytensor<T, N>::pytensor(const shape_type& shape, layout l)
200230 {
201231 compute_strides (shape, l, m_strides);
202232 init_tensor (shape, m_strides);
203233 }
204234
235+ /* *
236+ * Allocates a pytensor with the specified shape and layout. Elements
237+ * are initialized to the specified value.
238+ * @param shape the shape of the pytensor
239+ * @param value the value of the elements
240+ * @param l the layout of the pytensor
241+ */
205242 template <class T , std::size_t N>
206243 inline pytensor<T, N>::pytensor(const shape_type& shape,
207244 const_reference value,
@@ -212,6 +249,13 @@ namespace xt
212249 std::fill (m_data.begin (), m_data.end (), value);
213250 }
214251
252+ /* *
253+ * Allocates an uninitialized pytensor with the specified shape and strides.
254+ * Elements are initialized to the specified value.
255+ * @param shape the shape of the pytensor
256+ * @param strides the strides of the pytensor
257+ * @param value the value of the elements
258+ */
215259 template <class T , std::size_t N>
216260 inline pytensor<T, N>::pytensor(const shape_type& shape,
217261 const strides_type& strides,
@@ -221,26 +265,43 @@ namespace xt
221265 std::fill (m_data.begin (), m_data.end (), value);
222266 }
223267
268+ /* *
269+ * Allocates an uninitialized pytensor with the specified shape and strides.
270+ * @param shape the shape of the pytensor
271+ * @param strides the strides of the pytensor
272+ */
224273 template <class T , std::size_t N>
225274 inline pytensor<T, N>::pytensor(const shape_type& shape,
226275 const strides_type& strides)
227276 {
228277 init_tensor (shape, strides);
229278 }
230-
279+ // @}
280+
281+ /* *
282+ * @name Extended copy semantic
283+ */
284+ // @{
285+ /* *
286+ * The extended copy constructor.
287+ */
231288 template <class T , std::size_t N>
232289 template <class E >
233290 inline pytensor<T, N>::pytensor(const xexpression<E>& e)
234291 {
235292 semantic_base::assign (e);
236293 }
237294
295+ /* *
296+ * The extended assignment operator.
297+ */
238298 template <class T , std::size_t N>
239299 template <class E >
240300 inline auto pytensor<T, N>::operator =(const xexpression<E>& e) -> self_type&
241301 {
242302 return semantic_base::operator =(e);
243303 }
304+ // @}
244305
245306 template <class T , std::size_t N>
246307 inline auto pytensor<T, N>::ensure(pybind11::handle h) -> self_type
0 commit comments