8000 linalg.eigh incorrect results for complex data on osx-arm64 · Issue #287 · conda-forge/numpy-feedstock · GitHub
[go: up one dir, main page]

Skip to content
linalg.eigh incorrect results for complex data on osx-arm64 #287
@jcmgray

Description

@jcmgray

Solution to issue cannot be found in the documentation.

  • I checked the documentation.

Issue

On osx-arm64 with numpy==1.24 installed from conda-forge, np.linalg.eigh produces incorrect results for complex data types:

import numpy as np

d = 3
A = np.random.randn(d, d) + 1j * np.random.randn(d, d)
A = (A + A.conj().T)

el, ev = np.linalg.eigh(A)

# following should all be close to zero
print(np.linalg.norm(np.identity(d) - (ev @ ev.conj().T)))
# 4.115852147734368
print(np.linalg.norm(np.identity(d) - (ev.conj().T @ ev)))
# 4.115852147734368
print(np.linalg.norm(A - (ev @ np.diag(el) @ ev.conj().T)))
# 11.555496471473255

Other linalg such as svd appears to be working (though I haven't checked exhaustively).

I have checked this with:

  • blas=*=acclerate
  • blas=*=netlib

(Can't check with blas=*=openblas as this doesn't appear to work more generally)

Using numpy from pypi the code is working fine. Thus raising the issue here assuming it is something to do with the linked lapack, but apologies if this should be in the main numpy repo.

Possibly related to #21950, thought the issue here is not simply normalization of the eigenvectors.

Installed packages

# packages in environment at /Users/johnnie/conda/envs/numpy-latest:
#
# Name                    Version                   Build  Channel
bzip2                     1.0.8                h620ffc9_4  
ca-certificates           2022.10.11           hca03da5_0  
certifi                   2022.9.24       py311hca03da5_0  
libblas                   3.9.0           1_h9886b1c_netlib  
libcblas                  3.9.0           1_h9886b1c_netlib  
libcxx                    14.0.6               h848a8c0_0  
libffi                    3.4.2                hca03da5_6  
libgfortran               5.0.0           11_3_0_hca03da5_28  
libgfortran5              11.3.0              h009349e_28  
liblapack                 3.9.0           1_h9886b1c_netlib  
libsqlite                 3.40.0               h76d750c_0    conda-forge
libzlib                   1.2.13               h03a7124_4    conda-forge
llvm-openmp               14.0.6               hc6e5704_0  
ncurses                   6.3                  h1a28f6b_3  
numpy                     1.24.1          py311ha92fb03_0    conda-forge
openssl                   3.0.7                h03a7124_1    conda-forge
pip                       22.2.2          py311hca03da5_0  
python                    3.11.0          h3ba56d0_1_cpython    conda-forge
python_abi                3.11                    3_cp311    conda-forge
readline                  8.2                  h1a28f6b_0  
setuptools                65.5.0          py311hca03da5_0  
tk                        8.6.12               hb8d0fd4_0  
tzdata                    2022g                h04d1e81_0  
wheel                     0.37.1             pyhd3eb1b0_0  
xz                        5.2.8                h80987f9_0  
zlib                      1.2.13               h03a7124_4    conda-forge

Environment info

active environment : numpy-latest
    active env location : /Users/johnnie/conda/envs/numpy-latest
            shell level : 2
       user config file : /Users/johnnie/.condarc
 populated config files : /Users/johnnie/.condarc
          conda version : 22.11.1
    conda-build version : not installed
         python version : 3.9.15.final.0
       virtual packages : __archspec=1=arm64
                          __osx=13.1=0
                          __unix=0=0
       base environment : /Users/johnnie/conda  (writable)
      conda av data dir : /Users/johnnie/conda/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/osx-arm64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-arm64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://conda.anaconda.org/conda-forge/osx-arm64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /Users/johnnie/conda/pkgs
                          /Users/johnnie/.conda/pkgs
       envs directories : /Users/johnnie/conda/envs
                          /Users/johnnie/.conda/envs
               platform : osx-arm64
             user-agent : conda/22.11.1 requests/2.28.1 CPython/3.9.15 Darwin/22.2.0 OSX/13.1
                UID:GID : 501:20
             netrc file : None
           offline mode : False

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0