7 template <
typename DScalarType,
int Rows = Eigen::Dynamic,
int Cols = Eigen::Dynamic>
10 if constexpr (Rows != Eigen::Dynamic) {
13 if constexpr (Cols != Eigen::Dynamic) {
18 using RetType = Eigen::Matrix<DScalarType, Rows, Cols>;
19 if constexpr (Rows != Eigen::Dynamic && Cols != Eigen::Dynamic) {
20 return RetType::NullaryExpr([](
int row,
int col) {
22 if constexpr (RetType::IsRowMajor) {
23 index = Rows * col + row;
25 index = Cols * row + col;
27 return DScalarType(index);
31 return RetType::NullaryExpr(
34 [&](
int row,
int col) {
36 if constexpr (RetType::IsRowMajor) {
37 index = rows * col + row;
39 index = cols * row + col;
41 return DScalarType(index);
47 template <
typename DScalarType,
typename Derived>
50 constexpr
static int Rows = Derived::RowsAtCompileTime;
51 constexpr
static int Cols = Derived::ColsAtCompileTime;
52 int rows = data.rows();
53 int cols = data.cols();
57 using RetType = Eigen::Matrix<DScalarType, Rows, Cols>;
58 if constexpr (Rows != Eigen::Dynamic && Cols != Eigen::Dynamic) {
59 return RetType::NullaryExpr([&](
int row,
int col) {
61 if constexpr (RetType::IsRowMajor) {
62 index = Rows * col + row;
64 index = Cols * row + col;
66 return DScalarType(index, data(row, col));
70 return RetType::NullaryExpr(
73 [&](
int row,
int col) {
75 if constexpr (RetType::IsRowMajor) {
76 index = rows * col + row;
78 index = cols * row + col;
80 return DScalarType(index, data(row, col));
auto make_DScalar_matrix(int rows=0, int cols=0)
auto as_DScalar(const Eigen::MatrixBase< Derived > &data)
static size_t getVariableCount()
Get the variable count used by the automatic differentiation layer.