<p dir="auto">My issue is about to solve a sparse linear system is much slower in Scipy than in Matlab.</p>
<h3 dir="auto">Reproducing code example:</h3>

<p dir="auto">I tried the following script in python</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np
import scipy.sparse.linalg
import time
N = 6 
diagonals = np.zeros((3, N))   # 3 diagonals
diagonals[0,:] = np.linspace(-1, -N, N)
diagonals[1,:] = -2
diagonals[2,:] = np.linspace(1, N, N)
time1 = time.time()
A = scipy.sparse.spdiags(diagonals, [-1,0,1], N, N, format='csc')
print &quot;spdiags takes &quot; + str(time.time()-time1)
x = np.linspace(-1, 1, N)  # choose solution
b = A.dot(x)               # sparse matrix vector product
time1 = time.time()
x = scipy.sparse.linalg.spsolve(A, b)
print &quot;solve a linear system takes&quot; + str(time.time()-time1)
print x"><pre lang="import" class="notranslate"><code class="notranslate">import numpy as np
import scipy.sparse.linalg
import time
N = 6 
diagonals = np.zeros((3, N))   # 3 diagonals
diagonals[0,:] = np.linspace(-1, -N, N)
diagonals[1,:] = -2
diagonals[2,:] = np.linspace(1, N, N)
time1 = time.time()
A = scipy.sparse.spdiags(diagonals, [-1,0,1], N, N, format='csc')
print "spdiags takes " + str(time.time()-time1)
x = np.linspace(-1, 1, N)  # choose solution
b = A.dot(x)               # sparse matrix vector product
time1 = time.time()
x = scipy.sparse.linalg.spsolve(A, b)
print "solve a linear system takes" + str(time.time()-time1)
print x
</code></pre></div>
<p dir="auto">Result:</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="spdiags takes 0.000300168991089
solve a linear system takes0.000184059143066
[-1.  -0.6 -0.2  0.2  0.6  1. ]"><pre class="notranslate"><code class="notranslate">spdiags takes 0.000300168991089
solve a linear system takes0.000184059143066
[-1.  -0.6 -0.2  0.2  0.6  1. ]
</code></pre></div>
<p dir="auto">I also tried the following code in Matlab:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="N = 6;
diagonals = zeros(N, 3);
diagonals(:,1) = linspace(-1, -N, N);
diagonals(:,2) = -2;
diagonals(:,3) = linspace(1, N, N);
tic
A = spdiags(diagonals, -1:1,N,N);
toc
x = linspace(-1, 1, N)';
b = A * x;           
tic
x = A\b;
toc
x"><pre class="notranslate"><code class="notranslate">N = 6;
diagonals = zeros(N, 3);
diagonals(:,1) = linspace(-1, -N, N);
diagonals(:,2) = -2;
diagonals(:,3) = linspace(1, N, N);
tic
A = spdiags(diagonals, -1:1,N,N);
toc
x = linspace(-1, 1, N)';
b = A * x;           
tic
x = A\b;
toc
x
</code></pre></div>
<p dir="auto">Result:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Elapsed time is 0.000452 seconds.
Elapsed time is 0.000073 seconds.

x =

   -1.0000
   -0.6000
   -0.2000
    0.2000
    0.6000
    1.0000"><pre class="notranslate"><code class="notranslate">Elapsed time is 0.000452 seconds.
Elapsed time is 0.000073 seconds.

x =

   -1.0000
   -0.6000
   -0.2000
    0.2000
    0.6000
    1.0000
</code></pre></div>
<p dir="auto">It only takes 0.000073 seconds in Matlab while 0.000184059143066 in Scipy.</p>
<h3 dir="auto">Scipy/Numpy/Python version information:</h3>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)
('1.1.0', '1.13.3', sys.version_info(major=2, minor=7, micro=14, releaselevel='final', serial=0))"><pre class="notranslate"><code class="notranslate">import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)
('1.1.0', '1.13.3', sys.version_info(major=2, minor=7, micro=14, releaselevel='final', serial=0))
</code></pre></div>
<p dir="auto">I've found that on some page you have trouble with the latex markup</p>
<p dir="auto"><a href="http://docs.scipy.org/doc/scipy-0.15.1/reference/tutorial/linalg.html" rel="nofollow">http://docs.scipy.org/doc/scipy-0.15.1/reference/tutorial/linalg.html</a></p>
<p dir="auto">there is a lot of [ and ] that appear all over the text.</p>