The `memset` function and bitwise manipulation only apply to POD types
that do not require initialization, otherwise resulting in UB. We currently
violate this in `ptrue` and `pzero`, we assume bitmasks for `pselect`, and
bitwise operations are applied byte-by-byte in the generic implementations.
This is causing issues for scalar types that do require initialization
or that contain non-POD info such as pointers (#2201). We either break
them, or force specializations of these functions for custom scalars,
even if they are not vectorized.
Here we modify these functions for scalars only - instead using only
scalar operations:
- `pzero`: `Scalar(0)` for all scalars.
- `ptrue`: `Scalar(1)` for non-trivial scalars, bitset to one bits for trivial scalars.
- `pselect`: ternary select comparing mask to `Scalar(0)` for all scalars
- `pand`, `por`, `pxor`, `pnot`: use operators `&`, `|`, `^`, `~` for all integer or non-trivial scalars, otherwise apply bytewise.
For non-scalar types, the original implementations are used to maintain
compatibility and minimize the number of changes.
Fixes #2201.
(cherry picked from commit
|
||
|---|---|---|
| .gitlab | ||
| bench | ||
| blas | ||
| ci | ||
| cmake | ||
| debug | ||
| demos | ||
| doc | ||
| Eigen | ||
| failtest | ||
| lapack | ||
| scripts | ||
| test | ||
| unsupported | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .hgeol | ||
| CMakeLists.txt | ||
| COPYING.APACHE | ||
| COPYING.BSD | ||
| COPYING.GPL | ||
| COPYING.LGPL | ||
| COPYING.MINPACK | ||
| COPYING.MPL2 | ||
| COPYING.README | ||
| CTestConfig.cmake | ||
| CTestCustom.cmake.in | ||
| eigen3.pc.in | ||
| INSTALL | ||
| README.md | ||
| signature_of_eigen3_matrix_library | ||
Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.
For more information go to http://eigen.tuxfamily.org/.
For pull request, bug reports, and feature requests, go to https://gitlab.com/libeigen/eigen.