Skip to content

Commit 2e3f1e6

Browse files
authored
Merge pull request #2276 from JohanMabille/doc
Slight reorganization fo documentation
2 parents 083cd28 + 05c2762 commit 2e3f1e6

5 files changed

Lines changed: 48 additions & 57 deletions

File tree

docs/source/build-options.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ The following macros are helpers for debugging, they are not defined by default:
3939
- ``XTENSOR_ENABLE_CHECK_DIMENSION``: enables the dimensions check in ``xtensor``. Note that this option should not be turned
4040
on if you expect ``operator()`` to perform broadcasting.
4141

42+
.. _external-dependencies:
43+
4244
External dependencies
4345
---------------------
4446

docs/source/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ for details.
6969
missing
7070
histogram
7171
random
72-
sfinae
73-
xsimd
72+
rank
7473
file_loading
7574
build-options
7675
pitfall

docs/source/pitfall.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,45 @@ curious compilation error may occur on Windows:
132132
133133
To avoid this compiler bug (for which we don't have a workaround), ensure
134134
all the elements in the initializer list have the same type.
135+
136+
Alignment of fixed-size members
137+
-------------------------------
138+
139+
.. note::
140+
141+
If you are using ``C++ >= 17`` you should not have to worry about this.
142+
143+
When building with ``xsimd`` (see :ref:`external-dependencies`), if you define a structure
144+
having members of fixed-size xtensor types, you must ensure that the buffers properly
145+
aligned. For this you can use the macro ``XTENSOR_FIXED_ALIGN`` available in
146+
``xtensor/xtensor_config.hpp``.
147+
Consider the following example:
148+
149+
.. code-block:: cpp
150+
151+
template <typename T>
152+
class alignas(XTENSOR_FIXED_ALIGN) Foo
153+
{
154+
public:
155+
156+
using allocator_type = std::conditional_t<XTENSOR_FIXED_ALIGN != 0,
157+
xt_simd::aligned_allocator<T, XTENSOR_FIXED_ALIGN>,
158+
std::allocator<T>>;
159+
160+
Foo(T fac) : m_fac(fac)
161+
{
162+
m_bar.fill(fac);
163+
}
164+
165+
auto get() const
166+
{
167+
return m_bar;
168+
}
169+
170+
private:
171+
172+
xt::xtensor_fixed<T, xt::xshape<10, 10>> m_bar;
173+
T m_fac;
174+
};
175+
176+
Whereby it is important to store the fixed-sized xtensor type (in this case ``xt::xtensor_fixed<T, xt::xshape<10, 10>>``) as first member.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
55
The full license is in the file LICENSE, distributed with this software.
66
7-
.. _sfinae:
7+
.. _rank:
88

9-
SFINAE
10-
======
9+
Tensor Rank
10+
===========
1111

1212
Rank overload
1313
-------------

docs/source/xsimd.rst

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)