Skip to content

Audit implementations of functions in matrixtools.py. #429

Closed
@rileyjmurray

Description

@rileyjmurray

The matrixtools.py file is almost 3000 lines long. Some functions in this file are much less efficient than they could be. For example, the check for a valid density matrix is implemented as follows:

return is_hermitian(mx, tol) and is_pos_def(mx, tol) and abs(trace(mx) - 1.0) < tol

This is inefficient because Python will evaluate the boolean conditions from left to right, so we should start with the cheapest check and end with the most expensive check. What we actually see is that the cheapest check happens at the end and the most expensive check (requiring an eigendecomposition) happens in the middle.

I suspect there are many functions with subtle inefficiencies like this. I'm creating this issue so that I can make sure to sit down and do a proper audit of these functions, rather than identifying inefficiencies and fixing them piecemeal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions