For a Matrix :math: X=left ( a_{n,m} right )_{Ntimes M} with N variables from M observations, its covariance matrix can be expressed as:
\[C\left ( i,j \right )=\frac{1}{M-1}\sum_{m=0}^{M-1}\left ( a_{i,m}-\bar{a_{i}} \right )\left ( a_{jm}-\bar{a_{j}} \right )\]
where :math: i,jin left [ 0,N-1 right ], :math: a_{i,m} denotes m-th element of the i-th row, :math: bar{a_{i}} denotes the expected value (mean) of the all observations on the i-th row.
The variance-covariance matrix is symmetric because the element :math: cleft ( i,j right ) the same as the element :math: cleft ( j,i right ). Therefore, for the implementation of the covariance matrix, it only needs to calculate a lower triangular matrix.