I am using the Eigen library to factorize a matrix $A$ both using the Cholesky and the $LDL^T$ factorization.
Basically, I correctly compute a matrix $C$ and check that $$A=CC^T,$$ then I correctly compute $P$, $L$, and $D$, and check that $$A=P^TLDL^TP,$$ where $P$ is a permutation matrix generated by Eigen. However if $D=\sqrt D(\sqrt D)^T$, $$C\neq P^TL\sqrt D.$$
This is really counterintuitive for me. Is there any reason about this? Thanks a lot.
As copper.hat said in his comment, we generally cannot infer that $C=B$ if we only know that $CC^T=BB^T$.
However, to answer the question in OP's comment: this fact does not violate the uniqueness of the Cholesky factorization because to call $A=CC^T$ a "Cholesky factorization", we need that $C$ is lower-triangular; presumably the $P^TL\sqrt{D}$ that arose from the Eigen calculation was not lower-triangular.
(In particular, the uniqueness of Cholesky decomposition is a consequence of the uniqueness of $LU$ factorization.)