mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-11 17:00:34 +00:00
Fix eigen copying of non-standard stride values
Some Eigen objects, such as those returned by matrix.diagonal() and matrix.block() have non-standard stride values because they are basically just maps onto the underlying matrix without copying it (for example, the primary diagonal of a 3x3 matrix is a vector-like object with .src equal to the full matrix data, but with stride 4). Returning such an object from a pybind11 method breaks, however, because pybind11 assumes vectors have stride 1, and that matrices have strides equal to the number of rows/columns or 1 (depending on whether the matrix is stored column-major or row-major). This commit fixes the issue by making pybind11 use Eigen's stride methods when copying the data.
This commit is contained in:
@@ -33,3 +33,20 @@ cholesky3 OK
|
||||
cholesky4 OK
|
||||
cholesky5 OK
|
||||
cholesky6 OK
|
||||
diagonal() OK
|
||||
diagonal_1() OK
|
||||
diagonal_n(-5) OK
|
||||
diagonal_n(-4) OK
|
||||
diagonal_n(-3) OK
|
||||
diagonal_n(-2) OK
|
||||
diagonal_n(-1) OK
|
||||
diagonal_n(0) OK
|
||||
diagonal_n(1) OK
|
||||
diagonal_n(2) OK
|
||||
diagonal_n(3) OK
|
||||
diagonal_n(4) OK
|
||||
diagonal_n(5) OK
|
||||
diagonal_n(6) OK
|
||||
block(2,1,3,3) OK
|
||||
block(1,4,4,2) OK
|
||||
block(1,4,3,2) OK
|
||||
|
||||
Reference in New Issue
Block a user