title: Solving Ax=b with numpy linalg python raise LinAlgError('Incompatible dimensions')
body: <p>I am trying to solve Ax = b for x. </p>
  
  <p>A is a sparse matrix; x is unknown, and a b is a np.array. </p>
  
  <pre><code>print(type(matrix_a))
  print(type(vector_c))
  
  print("Matrix A Shape  -- %s " %str(matrix_a.shape))
  print("vector c shape -- %s " %len(vector_c))
  
  #xx = np.array([1],dtype=np.float32)
  
  vec_c = np.insert(vector_c,0,1)
  print("Update Vector c shape -- %s "% len(vec_c))
  
  new_matrix = matrix_a.todense()
  new_matrix_T = new_matrix.transpose()
  
  x = np.linalg.lstsq(new_matrix_T,vec_c)
  </code></pre>
  
  <p>yields the following output.</p>
  
  <blockquote>
    <p> 
     
    Matrix A Shape  -- (48002, 7651)<br>
    vector c shape -- 48001<br>
    Update Vector C shape -- 48002  </p>
  </blockquote>
  
  <p>Traceback (most recent call last):   File</p>
  
  <blockquote>
    <p>"/Users/<em>removed</em>/PycharmProjects/hw2/main.py", line 139, in 
        main()   File "/Users/<em>removed</em>/PycharmProjects/hw2/main.py", line 65, in main
        b1 = st.fit_parameters(A1, c)   File "/Users/<em>removed</em>/PycharmProjects/hw2/hw3_part1.py", line 191, in
    fit_parameters
        x = np.linalg.lstsq(new_matrix_T,vec_c)   File "/Users/<em>removed</em>/.conda/envs/hw2/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 1984, in lstsq
        raise LinAlgError('Incompatible dimensions') numpy.linalg.linalg.LinAlgError: Incompatible dimensions</p>
  </blockquote>