Skip to content

BUG: RuntimeWarning: divide by zero encountered in det for a complex matrix with all real values #25214

@astralcai

Description

@astralcai

Describe the issue:

When calculating the determinant of a complex matrix where all values are real, the function throws

RuntimeWarning: divide by zero encountered in det

Reproduce the code example:

import numpy as np
mat = [[1,0],[0,1]]
mat = np.asarray(mat, dtype="complex128")
np.linalg.det(mat)

Error message:

/Users/astralcai/Workspace/pennylane/venv/lib/python3.9/site-packages/numpy/linalg/linalg.py:2180: RuntimeWarning: divide by zero encountered in det
  r = _umath_linalg.det(a, signature=signature)
/Users/astralcai/Workspace/pennylane/venv/lib/python3.9/site-packages/numpy/linalg/linalg.py:2180: RuntimeWarning: invalid value encountered in det
  r = _umath_linalg.det(a, signature=signature)

Runtime information:

1.26.1
3.9.6 (default, Aug 11 2023, 19:44:49)
[Clang 15.0.0 (clang-1500.0.40.1)]

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions