[bug #68569] chol (A, "lower") uses the upper triangle when A is sparse

"Dmitri A. Sergatskov" <[email protected]> Sun, 26 Jul 2026 14:44:22 -0400 (EDT)
Newsgroups gmane.comp.gnu.octave.bugs
Message-ID <[email protected]>
--===============6506442662030769023==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

UGxlYXNlIHVzZSB0aGUgYnVnIHRyYWNrZXIgdG8gcG9zdCB1cGRhdGVzIHRvIGEgYnVnIHJlcG9y
dC4gIFRoZSBtYWlsaW5nIGxpc3QgaXMgaW50ZW5kZWQgYXMgYSByZWFkLW9ubHkgbm90aWZpY2F0
aW9uIHN0cmVhbS4gIEluZm8gcG9zdGVkIHRvIHRoaXMgbWFpbGluZyBsaXN0IGFkZHJlc3Mgd29u
J3QgYXBwZWFyIGluIHRoZSB0cmFja2VyIGRhdGFiYXNlIHdoZXJlIGl0IGlzIG1vc3QgdXNlZnVs
LgoK

--===============6506442662030769023==
Content-Type: MULTIPART/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; BOUNDARY="8323329-1714636915-1785091462=:1238431"
Content-Disposition: inline

--8323329-1714636915-1785091462=:1238431
Content-Type: TEXT/plain; CHARSET=utf-8
Content-Transfer-Encoding: QUOTED-PRINTABLE
Content-Disposition: inline

URL:=0A  <https://savannah.gnu.org/bugs/?68569>=0A=0A                 Summa=
ry: chol (A, "lower") uses the upper triangle when A is=0Asparse=0A        =
           Group: GNU Octave=0A               Submitter: dasergatskov=0A   =
            Submitted: Sun 26 Jul 2026 06:44:18 PM UTC=0A                Ca=
tegory: Octave Function=0A                Severity: 3 - Normal=0A          =
      Priority: 5 - Normal=0A              Item Group: Incorrect Result=0A =
                 Status: None=0A             Assigned to: None=0A         O=
riginator Name:=0A        Originator Email:=0A             Open/Closed: Ope=
n=0A         Discussion Lock: Unlocked=0A                 Release: dev=0A  =
      Operating System: Any=0A           Fixed Release: None=0A         Pla=
nned Release: None=0A=0A=0A    ____________________________________________=
___________=0A=0AFollow-up Comments:=0A=0A=0A------------------------------=
-------------------------=0ADate: Sun 26 Jul 2026 06:44:18 PM UTC By: Dmitr=
i A. Sergatskov <dasergatskov>=0AWhen called with "lower", chol should use =
only the lower triangle of the input=0Amatrix and treat the upper triangle =
as the transpose=0A(or conjugate transpose) of the lower triangle. For spar=
se inputs, chol=0Ainstead always uses the upper triangle.=0A=0A=0Aoctave:1>=
 A =3D [4, 3; 1, 1];=0Aoctave:2> [Ld, p_full] =3D chol (A, "lower")=0ALd =
=3D=0A=0A   2.0000        0=0A   0.5000   0.8660=0A=0Ap_full =3D 0=0Aoctave=
:3> [Ls, p_full] =3D chol (sparse(A), "lower")=0ALs =3D=0A=0ACompressed Col=
umn Sparse (rows =3D 2, cols =3D 1, nnz =3D 2 [100%])=0A=0A  (1, 1) -> 2=0A=
  (2, 1) -> 1.5000=0A=0Ap_full =3D 1=0Aoctave:4> Ld * Ld' =0Aans =3D=0A=0A =
  4   1=0A   1   1=0A=0Aoctave:5> Ls * Ls' =0Aans =3D=0A=0ACompressed Colum=
n Sparse (rows =3D 2, cols =3D 2, nnz =3D 4 [100%])=0A=0A  (1, 1) -> 4=0A  =
(2, 1) -> 3=0A  (1, 2) -> 3=0A  (2, 2) -> 2.2500=0A=0Aoctave:6> full(Ls * L=
s' )=0Aans =3D=0A=0A   4.0000   3.0000=0A   3.0000   2.2500=0A=0Aoctave:7> =
Ls =3D chol (sparse(A), "lower")=0Aerror: chol: input matrix must be positi=
ve definite=0A=0A=0A=0AFor "lower", the entry A(1,2) =3D 3 should be ignore=
d. The lower triangle=0Adefines the symmetric matrix A =3D [4,1;1,1]=0AThis=
 matrix is positive definite: its determinant is 3. =0A=0AThe dense call co=
mpletes the Cholesky factorization.=0AThe sparse call incorrectly reads the=
 upper triangle instead. That triangle=0Adefines A =3D [4,3;3,1] (determina=
nt is -5), so it is no positive definite.=0A=0AI will have a fix shortly.=
=0A=0ADmitri.=0A-- =0A=0A=0A=0A=0A=0A=0A=0A=0A    _________________________=
______________________________=0A=0AReply to this item at:=0A=0A  <https://=
savannah.gnu.org/bugs/?68569>=0A=0A________________________________________=
_______=0AMessage sent via Savannah=0Ahttps://savannah.gnu.org/=0A
--8323329-1714636915-1785091462=:1238431
Content-Type: APPLICATION/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCamZVhgAKCRCqLAuaBUf3
TtN5APwLJ6zYwYPw7qvUtmzPXANbO4tHMixT/oMBz5Kyc76r7wD/dDdldqV2+D4n
WwsBbQaHMMtcTC6LwCdNlPYJdeGiqA0=
=GRF9
-----END PGP SIGNATURE-----

--8323329-1714636915-1785091462=:1238431--



--===============6506442662030769023==--