Hello Statalist,
I am trying to multiply symmetric square matrices, A and B, in the following form:
C = A*B*A
where C should be a symmetric matrix of the same size as A and B. However, when I multiply using Mata, I end up with a non-symmetric matrix for C. I suspect that this has to do with the precision in multiplication as the elements in matrices A*B and C are both very close to zero (to the order of 10^-14 and smaller).
So far, I have tried using quadcross(A,B) to improve precision to no avail. Unfortunately, I cannot rule out a singular B, so it is not possible to decompose B into say B=LU and calculate C=(AL)*(UA). Is there any way in Mata to improve the precision in obtaining C?
Thanks,
Chang
I am trying to multiply symmetric square matrices, A and B, in the following form:
C = A*B*A
where C should be a symmetric matrix of the same size as A and B. However, when I multiply using Mata, I end up with a non-symmetric matrix for C. I suspect that this has to do with the precision in multiplication as the elements in matrices A*B and C are both very close to zero (to the order of 10^-14 and smaller).
So far, I have tried using quadcross(A,B) to improve precision to no avail. Unfortunately, I cannot rule out a singular B, so it is not possible to decompose B into say B=LU and calculate C=(AL)*(UA). Is there any way in Mata to improve the precision in obtaining C?
Thanks,
Chang
Comment