test_eigen_matrix.cpp
Go to the documentation of this file.
1 /*
2  tests/eigen.cpp -- automatic conversion of Eigen types
3 
4  Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
5 
6  All rights reserved. Use of this source code is governed by a
7  BSD-style license that can be found in the LICENSE file.
8 */
9 
10 <<<<<<<< HEAD:pybind11/tests/test_eigen.cpp
11 #include <pybind11/eigen.h>
12 ========
13 #include <pybind11/eigen/matrix.h>
14 >>>>>>>> 3a9158898134e05c9a2bb59b6f02ee7f7d7e18e0:pybind11/tests/test_eigen_matrix.cpp
15 #include <pybind11/stl.h>
16 
17 #include "constructor_stats.h"
18 #include "pybind11_tests.h"
19 
20 <<<<<<<< HEAD:pybind11/tests/test_eigen.cpp
21 #if defined(_MSC_VER)
22 # pragma warning(disable : 4996) // C4996: std::unary_negation is deprecated
23 #endif
24 ========
26 >>>>>>>> 3a9158898134e05c9a2bb59b6f02ee7f7d7e18e0:pybind11/tests/test_eigen_matrix.cpp
27 
28 #include <Eigen/Cholesky>
29 
31 
32 // Sets/resets a testing reference matrix to have values of 10*r + c, where r and c are the
33 // (1-based) row/column number.
34 template <typename M>
35 void reset_ref(M &x) {
36  for (int i = 0; i < x.rows(); i++) {
37  for (int j = 0; j < x.cols(); j++) {
38  x(i, j) = 11 + 10 * i + j;
39  }
40  }
41 }
42 
43 // Returns a static, column-major matrix
44 Eigen::MatrixXd &get_cm() {
45  static Eigen::MatrixXd *x;
46  if (!x) {
47  x = new Eigen::MatrixXd(3, 3);
48  reset_ref(*x);
49  }
50  return *x;
51 }
52 // Likewise, but row-major
53 MatrixXdR &get_rm() {
54  static MatrixXdR *x;
55  if (!x) {
56  x = new MatrixXdR(3, 3);
57  reset_ref(*x);
58  }
59  return *x;
60 }
61 // Resets the values of the static matrices returned by get_cm()/get_rm()
62 void reset_refs() {
63  reset_ref(get_cm());
64  reset_ref(get_rm());
65 }
66 
67 // Returns element 2,1 from a matrix (used to test copy/nocopy)
68 <<<<<<<< HEAD:pybind11/tests/test_eigen.cpp
69 double get_elem(const Eigen::Ref<const Eigen::MatrixXd> &m) { return m(2, 1); };
70 ========
71 double get_elem(const Eigen::Ref<const Eigen::MatrixXd> &m) { return m(2, 1); }
72 >>>>>>>> 3a9158898134e05c9a2bb59b6f02ee7f7d7e18e0:pybind11/tests/test_eigen_matrix.cpp
73 
74 // Returns a matrix with 10*r + 100*c added to each matrix element (to help test that the matrix
75 // reference is referencing rows/columns correctly).
76 template <typename MatrixArgType>
77 Eigen::MatrixXd adjust_matrix(MatrixArgType m) {
78  Eigen::MatrixXd ret(m);
79  for (int c = 0; c < m.cols(); c++) {
80  for (int r = 0; r < m.rows(); r++) {
81  ret(r, c) += 10 * r + 100 * c; // NOLINT(clang-analyzer-core.uninitialized.Assign)
82  }
83  }
84  return ret;
85 }
86 
88  CustomOperatorNew() = default;
89 
90  Eigen::Matrix4d a = Eigen::Matrix4d::Zero();
91  Eigen::Matrix4d b = Eigen::Matrix4d::Identity();
92 
94 };
95 
96 TEST_SUBMODULE(eigen_matrix, m) {
98  using FixedMatrixC = Eigen::Matrix<float, 5, 6>;
101  using FourRowMatrixC = Eigen::Matrix<float, 4, Eigen::Dynamic>;
102  using FourColMatrixC = Eigen::Matrix<float, Eigen::Dynamic, 4>;
103  using FourRowMatrixR = Eigen::Matrix<float, 4, Eigen::Dynamic>;
104  using FourColMatrixR = Eigen::Matrix<float, Eigen::Dynamic, 4>;
105  using SparseMatrixR = Eigen::SparseMatrix<float, Eigen::RowMajor>;
106  using SparseMatrixC = Eigen::SparseMatrix<float>;
107 
108  // various tests
109  m.def("double_col", [](const Eigen::VectorXf &x) -> Eigen::VectorXf { return 2.0f * x; });
110  m.def("double_row",
111  [](const Eigen::RowVectorXf &x) -> Eigen::RowVectorXf { return 2.0f * x; });
112  m.def("double_complex",
113  [](const Eigen::VectorXcf &x) -> Eigen::VectorXcf { return 2.0f * x; });
114  m.def("double_threec", [](py::EigenDRef<Eigen::Vector3f> x) { x *= 2; });
115  m.def("double_threer", [](py::EigenDRef<Eigen::RowVector3f> x) { x *= 2; });
116  m.def("double_mat_cm", [](const Eigen::MatrixXf &x) -> Eigen::MatrixXf { return 2.0f * x; });
117  m.def("double_mat_rm", [](const DenseMatrixR &x) -> DenseMatrixR { return 2.0f * x; });
118 
119  // test_eigen_ref_to_python
120  // Different ways of passing via Eigen::Ref; the first and second are the Eigen-recommended
121  m.def("cholesky1",
122  [](const Eigen::Ref<MatrixXdR> &x) -> Eigen::MatrixXd { return x.llt().matrixL(); });
123  m.def("cholesky2", [](const Eigen::Ref<const MatrixXdR> &x) -> Eigen::MatrixXd {
124  return x.llt().matrixL();
125  });
126  m.def("cholesky3",
127  [](const Eigen::Ref<MatrixXdR> &x) -> Eigen::MatrixXd { return x.llt().matrixL(); });
128  m.def("cholesky4", [](const Eigen::Ref<const MatrixXdR> &x) -> Eigen::MatrixXd {
129  return x.llt().matrixL();
130  });
131 
132  // test_eigen_ref_mutators
133  // Mutators: these add some value to the given element using Eigen, but Eigen should be mapping
134  // into the numpy array data and so the result should show up there. There are three versions:
135  // one that works on a contiguous-row matrix (numpy's default), one for a contiguous-column
136  // matrix, and one for any matrix.
137  auto add_rm = [](Eigen::Ref<MatrixXdR> x, int r, int c, double v) { x(r, c) += v; };
138  auto add_cm = [](Eigen::Ref<Eigen::MatrixXd> x, int r, int c, double v) { x(r, c) += v; };
139 
140  // Mutators (Eigen maps into numpy variables):
141  m.def("add_rm", add_rm); // Only takes row-contiguous
142  m.def("add_cm", add_cm); // Only takes column-contiguous
143  // Overloaded versions that will accept either row or column contiguous:
144  m.def("add1", add_rm);
145  m.def("add1", add_cm);
146  m.def("add2", add_cm);
147  m.def("add2", add_rm);
148  // This one accepts a matrix of any stride:
149  m.def("add_any",
150  [](py::EigenDRef<Eigen::MatrixXd> x, int r, int c, double v) { x(r, c) += v; });
151 
152  // Return mutable references (numpy maps into eigen variables)
153  m.def("get_cm_ref", []() { return Eigen::Ref<Eigen::MatrixXd>(get_cm()); });
154  m.def("get_rm_ref", []() { return Eigen::Ref<MatrixXdR>(get_rm()); });
155  // The same references, but non-mutable (numpy maps into eigen variables, but is !writeable)
156  m.def("get_cm_const_ref", []() { return Eigen::Ref<const Eigen::MatrixXd>(get_cm()); });
157  m.def("get_rm_const_ref", []() { return Eigen::Ref<const MatrixXdR>(get_rm()); });
158 
159  m.def("reset_refs", reset_refs); // Restores get_{cm,rm}_ref to original values
160 
161  // Increments and returns ref to (same) matrix
162  m.def(
163  "incr_matrix",
164  [](Eigen::Ref<Eigen::MatrixXd> m, double v) {
165  m += Eigen::MatrixXd::Constant(m.rows(), m.cols(), v);
166  return m;
167  },
168  py::return_value_policy::reference);
169 
170  // Same, but accepts a matrix of any strides
171  m.def(
172  "incr_matrix_any",
173  [](py::EigenDRef<Eigen::MatrixXd> m, double v) {
174  m += Eigen::MatrixXd::Constant(m.rows(), m.cols(), v);
175  return m;
176  },
177  py::return_value_policy::reference);
178 
179  // Returns an eigen slice of even rows
180  m.def(
181  "even_rows",
182  [](py::EigenDRef<Eigen::MatrixXd> m) {
183  return py::EigenDMap<Eigen::MatrixXd>(
184  m.data(),
185  (m.rows() + 1) / 2,
186  m.cols(),
187  py::EigenDStride(m.outerStride(), 2 * m.innerStride()));
188  },
189  py::return_value_policy::reference);
190 
191  // Returns an eigen slice of even columns
192  m.def(
193  "even_cols",
194  [](py::EigenDRef<Eigen::MatrixXd> m) {
195  return py::EigenDMap<Eigen::MatrixXd>(
196  m.data(),
197  m.rows(),
198  (m.cols() + 1) / 2,
199  py::EigenDStride(2 * m.outerStride(), m.innerStride()));
200  },
201  py::return_value_policy::reference);
202 
203  // Returns diagonals: a vector-like object with an inner stride != 1
204  m.def("diagonal", [](const Eigen::Ref<const Eigen::MatrixXd> &x) { return x.diagonal(); });
205  m.def("diagonal_1",
206  [](const Eigen::Ref<const Eigen::MatrixXd> &x) { return x.diagonal<1>(); });
207  m.def("diagonal_n",
208  [](const Eigen::Ref<const Eigen::MatrixXd> &x, int index) { return x.diagonal(index); });
209 
210  // Return a block of a matrix (gives non-standard strides)
211  m.def("block",
212 <<<<<<<< HEAD:pybind11/tests/test_eigen.cpp
214  int start_row,
215  int start_col,
216  int block_rows,
217  int block_cols) { return x.block(start_row, start_col, block_rows, block_cols); });
218 ========
219  [m](const py::object &x_obj,
220  int start_row,
221  int start_col,
222  int block_rows,
223  int block_cols) {
224  return m.attr("_block")(x_obj, x_obj, start_row, start_col, block_rows, block_cols);
225  });
226 
227  m.def(
228  "_block",
229  [](const py::object &x_obj,
231  int start_row,
232  int start_col,
233  int block_rows,
234  int block_cols) {
235  // See PR #4217 for background. This test is a bit over the top, but might be useful
236  // as a concrete example to point to when explaining the dangling reference trap.
237  auto i0 = py::make_tuple(0, 0);
238  auto x0_orig = x_obj[*i0].cast<double>();
239  if (x(0, 0) != x0_orig) {
240  throw std::runtime_error(
241  "Something in the type_caster for Eigen::Ref is terribly wrong.");
242  }
243  double x0_mod = x0_orig + 1;
244  x_obj[*i0] = x0_mod;
245  auto copy_detected = (x(0, 0) != x0_mod);
246  x_obj[*i0] = x0_orig;
247  if (copy_detected) {
248  throw std::runtime_error("type_caster for Eigen::Ref made a copy.");
249  }
250  return x.block(start_row, start_col, block_rows, block_cols);
251  },
252  py::keep_alive<0, 1>());
253 >>>>>>>> 3a9158898134e05c9a2bb59b6f02ee7f7d7e18e0:pybind11/tests/test_eigen_matrix.cpp
254 
255  // test_eigen_return_references, test_eigen_keepalive
256  // return value referencing/copying tests:
257  class ReturnTester {
258  Eigen::MatrixXd mat = create();
259 
260  public:
261  ReturnTester() { print_created(this); }
262  ~ReturnTester() { print_destroyed(this); }
263  static Eigen::MatrixXd create() { return Eigen::MatrixXd::Ones(10, 10); }
264  // NOLINTNEXTLINE(readability-const-return-type)
265  static const Eigen::MatrixXd createConst() { return Eigen::MatrixXd::Ones(10, 10); }
266  Eigen::MatrixXd &get() { return mat; }
267  Eigen::MatrixXd *getPtr() { return &mat; }
268  const Eigen::MatrixXd &view() { return mat; }
269  const Eigen::MatrixXd *viewPtr() { return &mat; }
270  Eigen::Ref<Eigen::MatrixXd> ref() { return mat; }
271  Eigen::Ref<const Eigen::MatrixXd> refConst() { return mat; }
272  Eigen::Block<Eigen::MatrixXd> block(int r, int c, int nrow, int ncol) {
273  return mat.block(r, c, nrow, ncol);
274  }
275  Eigen::Block<const Eigen::MatrixXd> blockConst(int r, int c, int nrow, int ncol) const {
276  return mat.block(r, c, nrow, ncol);
277  }
278  py::EigenDMap<Eigen::Matrix2d> corners() {
279  return py::EigenDMap<Eigen::Matrix2d>(
280  mat.data(),
281  py::EigenDStride(mat.outerStride() * (mat.outerSize() - 1),
282  mat.innerStride() * (mat.innerSize() - 1)));
283  }
284  py::EigenDMap<const Eigen::Matrix2d> cornersConst() const {
285  return py::EigenDMap<const Eigen::Matrix2d>(
286  mat.data(),
287  py::EigenDStride(mat.outerStride() * (mat.outerSize() - 1),
288  mat.innerStride() * (mat.innerSize() - 1)));
289  }
290  };
291  using rvp = py::return_value_policy;
292  py::class_<ReturnTester>(m, "ReturnTester")
293  .def(py::init<>())
294  .def_static("create", &ReturnTester::create)
295  .def_static("create_const", &ReturnTester::createConst)
296  .def("get", &ReturnTester::get, rvp::reference_internal)
297  .def("get_ptr", &ReturnTester::getPtr, rvp::reference_internal)
298  .def("view", &ReturnTester::view, rvp::reference_internal)
299  .def("view_ptr", &ReturnTester::view, rvp::reference_internal)
300  .def("copy_get", &ReturnTester::get) // Default rvp: copy
301  .def("copy_view", &ReturnTester::view) // "
302  .def("ref", &ReturnTester::ref) // Default for Ref is to reference
303  .def("ref_const", &ReturnTester::refConst) // Likewise, but const
304  .def("ref_safe", &ReturnTester::ref, rvp::reference_internal)
305  .def("ref_const_safe", &ReturnTester::refConst, rvp::reference_internal)
306  .def("copy_ref", &ReturnTester::ref, rvp::copy)
307  .def("copy_ref_const", &ReturnTester::refConst, rvp::copy)
308  .def("block", &ReturnTester::block)
309  .def("block_safe", &ReturnTester::block, rvp::reference_internal)
310  .def("block_const", &ReturnTester::blockConst, rvp::reference_internal)
311  .def("copy_block", &ReturnTester::block, rvp::copy)
312  .def("corners", &ReturnTester::corners, rvp::reference_internal)
313  .def("corners_const", &ReturnTester::cornersConst, rvp::reference_internal);
314 
315  // test_special_matrix_objects
316  // Returns a DiagonalMatrix with diagonal (1,2,3,...)
317  m.def("incr_diag", [](int k) {
319  for (int i = 0; i < k; i++) {
320  m.diagonal()[i] = i + 1;
321  }
322  return m;
323  });
324 
325  // Returns a SelfAdjointView referencing the lower triangle of m
326  m.def("symmetric_lower",
327  [](const Eigen::MatrixXi &m) { return m.selfadjointView<Eigen::Lower>(); });
328  // Returns a SelfAdjointView referencing the lower triangle of m
329  m.def("symmetric_upper",
330  [](const Eigen::MatrixXi &m) { return m.selfadjointView<Eigen::Upper>(); });
331 
332  // Test matrix for various functions below.
333  Eigen::MatrixXf mat(5, 6);
334  mat << 0, 3, 0, 0, 0, 11, 22, 0, 0, 0, 17, 11, 7, 5, 0, 1, 0, 11, 0, 0, 0, 0, 0, 11, 0, 0, 14,
335  0, 8, 11;
336 
337  // test_fixed, and various other tests
338  m.def("fixed_r", [mat]() -> FixedMatrixR { return FixedMatrixR(mat); });
339  // Our Eigen does a hack which respects constness through the numpy writeable flag.
340  // Therefore, the const return actually affects this type despite being an rvalue.
341  // NOLINTNEXTLINE(readability-const-return-type)
342  m.def("fixed_r_const", [mat]() -> const FixedMatrixR { return FixedMatrixR(mat); });
343  m.def("fixed_c", [mat]() -> FixedMatrixC { return FixedMatrixC(mat); });
344  m.def("fixed_copy_r", [](const FixedMatrixR &m) -> FixedMatrixR { return m; });
345  m.def("fixed_copy_c", [](const FixedMatrixC &m) -> FixedMatrixC { return m; });
346  // test_mutator_descriptors
347  m.def("fixed_mutator_r", [](const Eigen::Ref<FixedMatrixR> &) {});
348  m.def("fixed_mutator_c", [](const Eigen::Ref<FixedMatrixC> &) {});
349  m.def("fixed_mutator_a", [](const py::EigenDRef<FixedMatrixC> &) {});
350  // test_dense
351  m.def("dense_r", [mat]() -> DenseMatrixR { return DenseMatrixR(mat); });
352  m.def("dense_c", [mat]() -> DenseMatrixC { return DenseMatrixC(mat); });
353  m.def("dense_copy_r", [](const DenseMatrixR &m) -> DenseMatrixR { return m; });
354  m.def("dense_copy_c", [](const DenseMatrixC &m) -> DenseMatrixC { return m; });
355  // test_defaults
356  bool have_numpy = true;
357  try {
358  py::module_::import("numpy");
359  } catch (const py::error_already_set &) {
360  have_numpy = false;
361  }
362  if (have_numpy) {
363  py::module_::import("numpy");
364  Eigen::Matrix<double, 3, 3> defaultMatrix = Eigen::Matrix3d::Identity();
365  m.def("defaults_mat", [](const Eigen::Matrix3d &) {}, py::arg("mat") = defaultMatrix);
366 
367  Eigen::VectorXd defaultVector = Eigen::VectorXd::Ones(32);
368  m.def("defaults_vec", [](const Eigen::VectorXd &) {}, py::arg("vec") = defaultMatrix);
369  }
370  // test_sparse, test_sparse_signature
371  m.def("sparse_r", [mat]() -> SparseMatrixR {
372  // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn)
374  });
375  m.def("sparse_c",
376  [mat]() -> SparseMatrixC { return Eigen::SparseView<Eigen::MatrixXf>(mat); });
377  m.def("sparse_copy_r", [](const SparseMatrixR &m) -> SparseMatrixR { return m; });
378  m.def("sparse_copy_c", [](const SparseMatrixC &m) -> SparseMatrixC { return m; });
379  // test_partially_fixed
380  m.def("partial_copy_four_rm_r", [](const FourRowMatrixR &m) -> FourRowMatrixR { return m; });
381  m.def("partial_copy_four_rm_c", [](const FourColMatrixR &m) -> FourColMatrixR { return m; });
382  m.def("partial_copy_four_cm_r", [](const FourRowMatrixC &m) -> FourRowMatrixC { return m; });
383  m.def("partial_copy_four_cm_c", [](const FourColMatrixC &m) -> FourColMatrixC { return m; });
384 
385  // test_cpp_casting
386  // Test that we can cast a numpy object to a Eigen::MatrixXd explicitly
387  m.def("cpp_copy", [](py::handle m) { return m.cast<Eigen::MatrixXd>()(1, 0); });
388  m.def("cpp_ref_c", [](py::handle m) { return m.cast<Eigen::Ref<Eigen::MatrixXd>>()(1, 0); });
389  m.def("cpp_ref_r", [](py::handle m) { return m.cast<Eigen::Ref<MatrixXdR>>()(1, 0); });
390  m.def("cpp_ref_any",
391  [](py::handle m) { return m.cast<py::EigenDRef<Eigen::MatrixXd>>()(1, 0); });
392 
393  // [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works.
394 
395  // test_nocopy_wrapper
396  // Test that we can prevent copying into an argument that would normally copy: First a version
397  // that would allow copying (if types or strides don't match) for comparison:
398  m.def("get_elem", &get_elem);
399  // Now this alternative that calls the tells pybind to fail rather than copy:
400  m.def(
401  "get_elem_nocopy",
402  [](const Eigen::Ref<const Eigen::MatrixXd> &m) -> double { return get_elem(m); },
403  py::arg{}.noconvert());
404  // Also test a row-major-only no-copy const ref:
405  m.def(
406  "get_elem_rm_nocopy",
408  return m(2, 1);
409  },
410  py::arg{}.noconvert());
411 
412  // test_issue738, test_zero_length
413  // Issue #738: 1×N or N×1 2D matrices were neither accepted nor properly copied with an
414  // incompatible stride value on the length-1 dimension--but that should be allowed (without
415  // requiring a copy!) because the stride value can be safely ignored on a size-1 dimension.
416  // Similarly, 0×N or N×0 matrices were not accepted--again, these should be allowed since
417  // they contain no data. This particularly affects numpy ≥ 1.23, which sets the strides to
418  // 0 if any dimension size is 0.
419  m.def("iss738_f1",
420  &adjust_matrix<const Eigen::Ref<const Eigen::MatrixXd> &>,
421  py::arg{}.noconvert());
422  m.def("iss738_f2",
423  &adjust_matrix<const Eigen::Ref<const Eigen::Matrix<double, -1, -1, Eigen::RowMajor>> &>,
424  py::arg{}.noconvert());
425 
426  // test_issue1105
427  // Issue #1105: when converting from a numpy two-dimensional (Nx1) or (1xN) value into a dense
428  // eigen Vector or RowVector, the argument would fail to load because the numpy copy would
429  // fail: numpy won't broadcast a Nx1 into a 1-dimensional vector.
430  m.def("iss1105_col", [](const Eigen::VectorXd &) { return true; });
431  m.def("iss1105_row", [](const Eigen::RowVectorXd &) { return true; });
432 
433  // test_named_arguments
434  // Make sure named arguments are working properly:
435  m.def(
436  "matrix_multiply",
437  [](const py::EigenDRef<const Eigen::MatrixXd> &A,
438  const py::EigenDRef<const Eigen::MatrixXd> &B) -> Eigen::MatrixXd {
439  if (A.cols() != B.rows()) {
440  throw std::domain_error("Nonconformable matrices!");
441  }
442  return A * B;
443  },
444  py::arg("A"),
445  py::arg("B"));
446 
447  // test_custom_operator_new
448  py::class_<CustomOperatorNew>(m, "CustomOperatorNew")
449  .def(py::init<>())
450  .def_readonly("a", &CustomOperatorNew::a)
451  .def_readonly("b", &CustomOperatorNew::b);
452 
453  // test_eigen_ref_life_support
454  // In case of a failure (the caster's temp array does not live long enough), creating
455  // a new array (np.ones(10)) increases the chances that the temp array will be garbage
456  // collected and/or that its memory will be overridden with different values.
457  m.def("get_elem_direct", [](const Eigen::Ref<const Eigen::VectorXd> &v) {
458  py::module_::import("numpy").attr("ones")(10);
459  return v(5);
460  });
461  m.def("get_elem_indirect", [](std::vector<Eigen::Ref<const Eigen::VectorXd>> v) {
462  py::module_::import("numpy").attr("ones")(10);
463  return v[0](5);
464  });
465 }
create
ADT create(const Signature &signature)
Definition: testAlgebraicDecisionTree.cpp:145
Eigen::SparseMatrix
A versatible sparse matrix representation.
Definition: SparseMatrix.h:96
B
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:49
Eigen::DiagonalMatrix
Represents a diagonal matrix with its storage.
Definition: DiagonalMatrix.h:140
get_rm
MatrixXdR & get_rm()
Definition: test_eigen_matrix.cpp:53
Eigen::Block
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
return_value_policy
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
Definition: wrap/pybind11/include/pybind11/detail/common.h:518
reset_ref
void reset_ref(M &x)
Definition: test_eigen_matrix.cpp:35
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
TEST_SUBMODULE
TEST_SUBMODULE(eigen_matrix, m)
Definition: test_eigen_matrix.cpp:96
stl.h
Eigen::Upper
@ Upper
Definition: Constants.h:211
copy
int EIGEN_BLAS_FUNC() copy(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
Definition: level1_impl.h:29
test_eigen_matrix.ref
ref
Definition: test_eigen_matrix.py:11
get_cm
Eigen::MatrixXd & get_cm()
Definition: test_eigen_matrix.cpp:44
mat
MatrixXf mat
Definition: Tutorial_AdvancedInitialization_CommaTemporary.cpp:1
corners
void corners(const MatrixType &m)
Definition: corners.cpp:16
constructor_stats.h
block
m m block(1, 0, 2, 2)<< 4
A
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:48
view
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set view
Definition: gnuplot_common_settings.hh:27
matrix.h
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
make_tuple
tuple make_tuple()
Definition: cast.h:1390
noxfile.tests
None tests(nox.Session session)
Definition: noxfile.py:22
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Definition: Memory.h:841
arg
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE ArgReturnType arg() const
Definition: ArrayCwiseUnaryOps.h:66
Eigen::Lower
@ Lower
Definition: Constants.h:209
i0
double i0(double x)
Definition: i0.c:149
Eigen::Ref
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:281
CustomOperatorNew::CustomOperatorNew
CustomOperatorNew()=default
reset_refs
void reset_refs()
Definition: test_eigen_matrix.cpp:62
PYBIND11_WARNING_DISABLE_MSVC
PYBIND11_WARNING_PUSH PYBIND11_WARNING_DISABLE_MSVC(5054) PYBIND11_WARNING_POP static_assert(EIGEN_VERSION_AT_LEAST(3
pybind11_tests.h
print_destroyed
void print_destroyed(T *inst, Values &&...values)
Definition: constructor_stats.h:314
Eigen::SparseView
Expression of a dense or sparse matrix with zero or too small values removed.
Definition: ForwardDeclarations.h:124
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
pybind11
Definition: wrap/pybind11/pybind11/__init__.py:1
ret
return ret
Definition: test_eigen_matrix.cpp:84
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition: 3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
eigen.h
test_eigen_matrix
Definition: test_eigen_matrix.py:1
CustomOperatorNew
Definition: test_eigen_matrix.cpp:87
CustomOperatorNew::a
Eigen::Matrix4d a
Definition: test_eigen_matrix.cpp:90
get
Container::iterator get(Container &c, Position position)
Definition: stdlist_overload.cpp:29
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
print_created
void print_created(T *inst, Values &&...values)
Definition: constructor_stats.h:309
CustomOperatorNew::b
Eigen::Matrix4d b
Definition: test_eigen_matrix.cpp:91
M
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:51


gtsam
Author(s):
autogenerated on Wed Mar 19 2025 03:06:17