title: My python code which uses scipy is throwing a value error
body: <p>I have the following question and I have coded the following for it:</p>
  <pre><code>def prob6():
  &quot;&quot;&quot;Time regular and sparse linear system solvers.
  
  For various values of n, generate the (n**2,n**2) matrix A described of
  prob5() and vector b of length n**2. Time how long it takes to solve the
  system Ax = b with each of the following approaches:
  
      1. Convert A to CSR format and use scipy.sparse.linalg.spsolve()
      2. Convert A to a NumPy array and use scipy.linalg.solve().
  
  In each experiment, only time how long it takes to solve the system (not
  how long it takes to convert A to the appropriate format). Plot the system
  size n**2 versus the execution times. As always, use log scales where
  appropriate and use a legend to label each line.
  &quot;&quot;&quot;
  #raise NotImplementedError(&quot;Problem 6 Incomplete&quot;)
  
  n = 2**np.arange(1,5)
  
  time1 = []
  time2 = []
  
  
  
  for i in n:
      diagonals = [[1],[-4],[1]]
      offsets = [-1,0, 1]
      B = (sparse.diags(diagonals, offsets, shape=(i,i)))
      A = sparse.block_diag(([B]*i))
      A.setdiag(1,i)
      A.setdiag(1,-i)
      A.setdiag(1,-i)
      print(A.toarray())
      b = np.random.random(i*i)
      Acsr = A.tocsr()
      start = time.time()
      Acsr_final = spla.spsolve(A,b)
      time1.append(time.time() - start)
  
  for i in n:
      diagonals = [[1],[-4],[1]]
      offsets = [-1,0, 1]
      B = (sparse.diags(diagonals, offsets, shape=(i,i)))
      A = sparse.block_diag(([B]*i))
      A.setdiag(1,i)
      A.setdiag(1,-i)
      A.setdiag(1,-i)
      A.toarray()
      b = np.random.random(i*i)
      Anpa = np.squeeze(np.asarray(A))
      start = time.time()
      Anpa_final = sp.linalg.solve(A,b)
      time2.append(time.time() - start)
  
  plt.loglog(n, time1, 'm.-', lw=2, ms=15, label=&quot;time 1&quot;)
  plt.loglog(n, time2, 'g.-', lw=2, ms=15, label=&quot;time 2&quot;)
  plt.legend()
  plt.title(&quot;Times regular and sparse linear system solvers&quot;)
  plt.xlabel(&quot;n&quot;, fontsize=14)
  plt.ylabel(&quot;Seconds&quot;, fontsize=14)
  plt.show()
  </code></pre>
  <p>prob6()</p>
  <p>It keeps throwing the following ValueError on line 243 and I can't seem to solve it. It seems to have a problem with one of my scipy functions. I'm also not sure if what I've done is correct, so that may also be confusing things. Can anyone help?</p>
  <pre><code>ValueError: Sparse matrices are not supported by this function. Perhaps one of the scipy.sparse.linalg functions would work instead.
  </code></pre>