<p dir="auto"><code class="notranslate">scipy.linalg.eigvalsh()</code> give a message</p>
<blockquote>
<p dir="auto">Intel MKL ERROR: Parameter 12 was incorrect on entry to ZHBRDB.</p>
</blockquote>
<p dir="auto">and return  wrong eigenvalues. When the input matrix is a <strong>real Hermitian</strong>  matrix or a <strong>complex Hermitian with dimension less than 200</strong>0, this function always give the right answer as <code class="notranslate">np.linalg.eigvalsh</code> does, but if the matrix is a <strong>complex matrix with dimension larger than 2000</strong>, this function always give the above message and wrong eigenvalues. The returned eigenvalues are all zeros but the last one.</p>
<h3 dir="auto">Reproducing code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import scipy.linalg as la
import numpy as np

#row = col = 1999
row = col = 2000
shape = (row, col)

# A real matrix
#M = np.random.random(size=shape)

# A complex matrix
M = np.random.random(size=shape) + np.random.random(size=shape) * 1j

# Construct an Hermitian matrix
M += M.T.conj()

vals_numpy = np.linalg.eigvalsh(M)
vals_scipy = la.eigvalsh(M)
print(vals_scipy)
assert np.allclose(vals_numpy, vals_scipy)
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">scipy</span>.<span class="pl-s1">linalg</span> <span class="pl-k">as</span> <span class="pl-s1">la</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-c">#row = col = 1999</span>
<span class="pl-s1">row</span> <span class="pl-c1">=</span> <span class="pl-s1">col</span> <span class="pl-c1">=</span> <span class="pl-c1">2000</span>
<span class="pl-s1">shape</span> <span class="pl-c1">=</span> (<span class="pl-s1">row</span>, <span class="pl-s1">col</span>)

<span class="pl-c"># A real matrix</span>
<span class="pl-c">#M = np.random.random(size=shape)</span>

<span class="pl-c"># A complex matrix</span>
<span class="pl-v">M</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">random</span>(<span class="pl-s1">size</span><span class="pl-c1">=</span><span class="pl-s1">shape</span>) <span class="pl-c1">+</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">random</span>(<span class="pl-s1">size</span><span class="pl-c1">=</span><span class="pl-s1">shape</span>) <span class="pl-c1">*</span> <span class="pl-c1">1j</span>

<span class="pl-c"># Construct an Hermitian matrix</span>
<span class="pl-v">M</span> <span class="pl-c1">+=</span> <span class="pl-v">M</span>.<span class="pl-v">T</span>.<span class="pl-en">conj</span>()

<span class="pl-s1">vals_numpy</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">linalg</span>.<span class="pl-en">eigvalsh</span>(<span class="pl-v">M</span>)
<span class="pl-s1">vals_scipy</span> <span class="pl-c1">=</span> <span class="pl-s1">la</span>.<span class="pl-en">eigvalsh</span>(<span class="pl-v">M</span>)
<span class="pl-en">print</span>(<span class="pl-s1">vals_scipy</span>)
<span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">allclose</span>(<span class="pl-s1">vals_numpy</span>, <span class="pl-s1">vals_scipy</span>)</pre></div>
<h3 dir="auto">Error message:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
Intel MKL ERROR: Parameter 12 was incorrect on entry to ZHBRDB.
[    0.     0.     0. ...     0.     0. 48000.]
Traceback (most recent call last):
  File &quot;.\test.py&quot;, line 20, in &lt;module&gt;
    assert np.allclose(vals_numpy, vals_scipy)
AssertionError"><pre class="notranslate"><span class="pl-v">Intel</span> <span class="pl-v">MKL</span> <span class="pl-v">ERROR</span>: <span class="pl-v">Parameter</span> <span class="pl-c1">12</span> <span class="pl-s1">was</span> <span class="pl-s1">incorrect</span> <span class="pl-s1">on</span> <span class="pl-s1">entry</span> <span class="pl-s1">to</span> <span class="pl-v">ZHBRDB</span>.
[    <span class="pl-c1">0.</span>     <span class="pl-c1">0.</span>     <span class="pl-c1">0.</span> ...     <span class="pl-c1">0.</span>     <span class="pl-c1">0.</span> <span class="pl-c1">48000.</span>]
<span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>):
  <span class="pl-v">File</span> <span class="pl-s">".<span class="pl-cce">\t</span>est.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">20</span>, <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>
    <span class="pl-s1">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">allclose</span>(<span class="pl-s1">vals_numpy</span>, <span class="pl-s1">vals_scipy</span>)
<span class="pl-v">AssertionError</span></pre></div>
<h3 dir="auto">Scipy/Numpy/Python version information:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
scipy.__version__: '1.0.0'
numpy.__version: '1.14.2'
sys.version_info: sys.version_info(major=3, minor=6, micro=4, releaselevel='final', serial=0)
Python 3.6.4 :: Anaconda custom (64-bit)"><pre class="notranslate"><span class="pl-s1">scipy</span>.<span class="pl-s1">__version__</span>: <span class="pl-s">'1.0.0'</span>
<span class="pl-s1">numpy</span>.<span class="pl-s1">__version</span>: <span class="pl-s">'1.14.2'</span>
<span class="pl-s1">sys</span>.<span class="pl-s1">version_info</span>: <span class="pl-s1">sys</span>.<span class="pl-en">version_info</span>(<span class="pl-s1">major</span><span class="pl-c1">=</span><span class="pl-c1">3</span>, <span class="pl-s1">minor</span><span class="pl-c1">=</span><span class="pl-c1">6</span>, <span class="pl-s1">micro</span><span class="pl-c1">=</span><span class="pl-c1">4</span>, <span class="pl-s1">releaselevel</span><span class="pl-c1">=</span><span class="pl-s">'final'</span>, <span class="pl-s1">serial</span><span class="pl-c1">=</span><span class="pl-c1">0</span>)
<span class="pl-v">Python</span> <span class="pl-c1">3.6</span><span class="pl-c1">.4</span> :: <span class="pl-v">Anaconda</span> <span class="pl-s1">custom</span> (<span class="pl-c1">64</span><span class="pl-c1">-</span><span class="pl-s1">bit</span>)</pre></div>
<p dir="auto"><code class="notranslate">scipy.linalg.eigvalsh()</code> throws ValueError() for large matrices. The bug appears for arbitrary matrices.</p>
<p dir="auto">However, it also shows up in trivial examples, such as a large identity matrix, and large diagonal matrices with random coefficients in [0,1].</p>
<h3 dir="auto">Reproducing code example:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np 
import scipy.linalg as la

H=np.eye(6470)
#np.random.seed(0)
#H=np.diag(np.random.uniform(size=6470))
E=la.eigvalsh(H)"><pre class="notranslate"><code class="notranslate">import numpy as np 
import scipy.linalg as la

H=np.eye(6470)
#np.random.seed(0)
#H=np.diag(np.random.uniform(size=6470))
E=la.eigvalsh(H)
</code></pre></div>
<h3 dir="auto">Error message:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;example0.py&quot;, line 7, in &lt;module&gt;
    E=la.eigvalsh(H)
  File &quot;/Users/mbukov/anaconda3/lib/python3.6/site-packages/scipy/linalg/decomp.py&quot;, line 734, in eigvalsh
    check_finite=check_finite)
  File &quot;/Users/mbukov/anaconda3/lib/python3.6/site-packages/scipy/linalg/decomp.py&quot;, line 384, in eigh
    iu=a1.shape[0], overwrite_a=overwrite_a)
ValueError: On entry to DSBRDB parameter number 12 had an illegal value"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "example0.py", line 7, in &lt;module&gt;
    E=la.eigvalsh(H)
  File "/Users/mbukov/anaconda3/lib/python3.6/site-packages/scipy/linalg/decomp.py", line 734, in eigvalsh
    check_finite=check_finite)
  File "/Users/mbukov/anaconda3/lib/python3.6/site-packages/scipy/linalg/decomp.py", line 384, in eigh
    iu=a1.shape[0], overwrite_a=overwrite_a)
ValueError: On entry to DSBRDB parameter number 12 had an illegal value
</code></pre></div>
<h3 dir="auto">Scipy/Numpy/Python version information:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="0.19.1 1.13.0 sys.version_info(major=3, minor=6, micro=2, releaselevel='final', serial=0)"><pre class="notranslate"><code class="notranslate">0.19.1 1.13.0 sys.version_info(major=3, minor=6, micro=2, releaselevel='final', serial=0)
</code></pre></div>