Skip to content

wrong reconstruction of covariance matrix after eigenvalue decomposition #15

@FuZhiyu

Description

@FuZhiyu

In utils.jl, there is a mistake in the formula below when it reconstructs the covariance matrix after eigen decomposition:

return Symmetric(eigvect' * Diagonal(eigval) * eigvect)

The correct order should be:

eigvect * Diagonal(eigval) * eigvect'

i.e., the first matrix is not transposed while the last is. To quickly check,

using LinearAlgebra;
A = Symmetric(rand(3,3));
eigval, eigvect = eigen(A);
norm(eigvect * Diagonal(eigval) * eigvect' - A) < 1e-12  # true
norm(eigvect' * Diagonal(eigval) * eigvect - A) < 1e-12  # false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions