(checkcholesky(m,r) := (
  l : cholesky(m,r),
  l : m - l . ctranspose(l),
  if blockmatrixp(l) then l : mat_fullunblocker(l),
  every(lambda([x], is(cabs(x) < 1.0e-10)),l)),0);
0$

/*-----------*/
(m : matrix([0]),0);
0$

(ok : true,0);
0$

(for r in [floatfield, complexfield, generalring, rationalfield, crering, noncommutingring] do (
  ok : ok and checkcholesky(m,r)),ok);

true$


/*-----------*/
(m : matrix([1]),0);
0$

(ok : true,0);
0$

(for r in [floatfield, complexfield, generalring, rationalfield, crering, noncommutingring] do (
  ok : ok and checkcholesky(m,r)),ok);

true$

/*-----------*/
(m : matrix([1,0],[7,-8]),0);
0$

(m : m . ctranspose(m),0);
0$

(ok : true,0);
0$

(for r in [floatfield, complexfield, generalring, crering, noncommutingring] do (
  ok : ok and checkcholesky(m,r)),ok);
true$

/*-----------*/
(m : matrix([1,0],[7,-%i]),0);
0$

(m : m . ctranspose(m),0);
0$

(ok : true,0);
0$

(for r in [complexfield, generalring] do (
  ok : ok and checkcholesky(m,r)),ok);
true$


/*-----------*/
(m : matrix([1,0],[%i,5]),0);
0$

(m : m . ctranspose(m),0);
0$

(ok : true,0);
0$

(for r in [complexfield, generalring, noncommutingring] do (
  ok : ok and checkcholesky(m,r)),ok);
true$

/*-----------*/

(m : matrix([7-%i,0],[1-%i,5 + %i]),0);
0$

(m : expand(m . ctranspose(m)),0);
0$

(ok : true,0);
0$

(for r in [complexfield, noncommutingring] do (
  ok : ok and checkcholesky(m,r)),ok);
true$

/*------------*/

(m : matrix([matrix([1,0],[%i,10]), matrix([0,0],[0,0])], [matrix([1,2],[5,%i]),matrix([1,0],[2,8])]),0);
0$

(matrix_element_transpose : 'transpose, matrix_element_mult : ".", 0);
0$

(m : m . ctranspose(m),0);
0$

checkcholesky(m, noncommutingring);
true$

(matrix_element_transpose : false, matrix_element_mult : "*", 0);
0$

/*---------------*/
(ma[i,j] := kron_delta(i,j) + kron_delta(i,j+1)/2 + kron_delta(i,j-1)/2,0);
0$

(m : genmatrix(ma,71,71),0);
0$

checkcholesky(m,floatfield);
true$

(m : matrix([matrix([matrix([8,4],[4,13]),matrix([2,4],[7,9])],[matrix([2,7],[4,9]),matrix([10,6],[6,15])]),matrix([matrix([4,4],[12,5]),matrix([0,6],[6,8])],[matrix([8,3],[13,3]),matrix([6,5],[5,6])])],[matrix([matrix([4,12],[4,5]),matrix([8,13],[3,3])],[matrix([0,6],[6,8]),matrix([6,5],[5,6])]),matrix([matrix([18,5],[5,4]),matrix([5,9],[2,6])],[matrix([5,2],[9,6]),matrix([6,3],[3,11])])]),0);
0$

(matrix_element_transpose : 'transpose,0);
0$

(matrix_element_mult : ".",0);
0$

(m1 : cholesky(m.transpose(m), 'noncommutingring),0);
0$

zeromatrixp(factor(m1.transpose(m1) - m.transpose(m)));
true$

/*----clean up----*/

(remfunction(checkcholesky),0);
0$

(matrix_element_transpose : false,0);
0$

(matrix_element_mult : "*",0);
0$

(remvalue(m,m1,ok),0);
0$

(remarray(ma),0);
0$







