# [SciPy-User] what is linsolve? sparse docs

josef.pktd@gmai... josef.pktd@gmai...
Sun Oct 24 19:32:54 CDT 2010

```On Sun, Oct 24, 2010 at 3:26 PM, Warren Weckesser
<warren.weckesser@enthought.com> wrote:
>
>
> On Sun, Oct 24, 2010 at 1:09 PM, <josef.pktd@gmail.com> wrote:
>>
>> (from a question on ask.scipy.org)
>>
>> The docs for scipy sparse
>>
>> http://docs.scipy.org/doc/scipy/reference/sparse.html?highlight=linsolve
>>
>> contain an example that imports linsolve.
>>
>> I cannot find anything like this. Is this a historical artifact or
>> some hidden module somewhere ?
>>
>> Can someone who knows this update the examples?
>
>
> I just updated scipy/sparse/info.py, which is where this documentation comes
> from.  That file was last touched three years ago, and there have been
> changes in the source code since then.
>
> Here's a script containing the same code as in updated "Example 1" of that
> docstring:
>
> -----
> from scipy.sparse import lil_matrix
> from scipy.sparse.linalg import spsolve
> from numpy.linalg import solve, norm
> from numpy.random import rand
>
> A = lil_matrix((1000, 1000))
> A[0, :100] = rand(100)
> A[1, 100:200] = A[0, :100]
> A.setdiag(rand(1000))
>
> # Now convert it to CSR format and solve A x = b for x:
>
> A = A.tocsr()
> b = rand(1000)
> x = spsolve(A, b)
>
> # Convert it to a dense matrix and solve, and check that the result
> # is the same:
>
> x_ = solve(A.todense(), b)
>
> # Now we can compute norm of the error with:
>
> err = norm(x-x_)
> print err < 1e-10
> -----

Josef

>
> Warren
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
```