I have been trying for the last week to calculate the logarithm of the absolute value of the determinant of the Jacobian matrix of a transformation from one square matrix to another and am attempting to verify my math. Has anyone used the unsupported AutoDiff module in Eigen with stan::math::var as the underlying type? Here is a simple example file testJ.cpp (1.1 KB)

yields the correct answer for a matrix inverse transformation, but I don’t know if I can hook something like this into a Stan program without having to do some memory management stuff to prevent memory leaks. Download the attachment and then do in R

```
library(Rcpp)
sourceCpp("testJ.cpp")
K <- 3L
A <- matrix(rnorm(K ^ 2), K, K)
test_Jacobian(A) # yields same value as the next line
-2 * K * log(abs(det(A)))
```