cholesky_corr_free() checks only that its input is square. It does not verify
that the matrix is lower triangular, has a positive diagonal, or has unit row
norms. The source already notes the missing validation, and
check_cholesky_factor_corr() implements the required checks.
Minimal repro against develop at 344d7167a:
Eigen::MatrixXd bad(2, 2);
bad << 1.0, 0.0,
0.5, 0.5; // second row does not have unit norm
auto z = stan::math::cholesky_corr_free(bad);
auto roundtrip = stan::math::cholesky_corr_constrain(z, 2);
std::cout << (roundtrip - bad).cwiseAbs().maxCoeff();
Actual result:
The inverse transform accepts a value outside its domain and returns an
unconstrained vector that does not reconstruct the input. Other invalid inputs
can reach square roots with negative arguments.
Call check_cholesky_factor_corr() before the transform. Add rejection tests for
a nonzero upper triangle, nonpositive diagonal, non-unit row, excessive partial
row norm, and nonfinite entries, plus a valid round-trip test.
cholesky_corr_free()checks only that its input is square. It does not verifythat the matrix is lower triangular, has a positive diagonal, or has unit row
norms. The source already notes the missing validation, and
check_cholesky_factor_corr()implements the required checks.Minimal repro against
developat344d7167a:Actual result:
The inverse transform accepts a value outside its domain and returns an
unconstrained vector that does not reconstruct the input. Other invalid inputs
can reach square roots with negative arguments.
Call
check_cholesky_factor_corr()before the transform. Add rejection tests fora nonzero upper triangle, nonpositive diagonal, non-unit row, excessive partial
row norm, and nonfinite entries, plus a valid round-trip test.