Closed gftabor closed 2 years ago
Just updating this, the indexing is correct with C++ codegen which I imagine is why it was never noticed.
void ErrorFactor(const Eigen::Matrix<Scalar, 10, 4>& A, const Eigen::Matrix<Scalar, 10, 4>& B,
const Eigen::Matrix<Scalar, 4, 1>& x,
Eigen::Matrix<Scalar, 1, 1>* const res = nullptr,
Eigen::Matrix<Scalar, 1, 4>* const jacobian = nullptr,
Eigen::Matrix<Scalar, 4, 4>* const hessian = nullptr,
Eigen::Matrix<Scalar, 4, 1>* const rhs = nullptr) {
// Total ops: 2559
// Input arrays
// Intermediate terms (515)
const Scalar _tmp0 =
A(0, 0) * B(0, 0) + A(0, 1) * B(0, 1) + A(0, 2) * B(0, 2) + A(0, 3) * B(0, 3);
const Scalar _tmp1 = A(0, 0) * _tmp0;
Describe the bug Python codegen with matrix doesn't expect correct dimensions? The input dimensions were correctly put in args 10x4 for A and B but the codegen calls element 30. When I pass a matrix of 10x4 to my generated function it throws an error because 30 isn't possible, it seems the codegen expects me to flatten the array before passing it in.
` def error_factor(A, B, x):
type: (numpy.ndarray, numpy.ndarray, T.Sequence[float]) -> T.Tuple[T.List[float], numpy.ndarray, numpy.ndarray, T.List[float]]
To Reproduce
Expected behavior Codegen should index elements correctly from the input shape.
Environment (please complete the following information):