File: info.py

package info (click to toggle)
python-scipy 0.5.2-0.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 33,888 kB
  • ctags: 44,231
  • sloc: ansic: 156,256; cpp: 90,347; python: 89,604; fortran: 73,083; sh: 1,318; objc: 424; makefile: 342
file content (51 lines) | stat: -rw-r--r-- 1,435 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
Linear Solvers
==============

The default solver is SuperLU (included in the scipy distribution), which can
solve real or complex linear systems in both single and double precisions.  It
is automatically replaced by UMFPACK, if available. Note that UMFPACK works in
double precision only, so switch it off by
>>> use_solver( use = {'useUmfpack': False} )
to solve in the single precision.

Example session:

>>> from scipy.sparse import csc_matrix
>>> from numpy import array
>>> from scipy.linsolve import spdiags, spsolve, use_solver
>>>
>>> print "Inverting a sparse linear system:"
>>> print "The sparse matrix (constructed from diagonals):"
>>> a = spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]], [0, 1], 5, 5)
>>> b = array([1, 2, 3, 4, 5])
>>> print "Solve: single precision complex:"
>>> use_solver( use = {'useUmfpack' : False} )
>>> a = a.astype('F')
>>> x = spsolve(a, b)
>>> print x
>>> print "Error: ", a*x-b
>>>
>>> print "Solve: double precision complex:"
>>> use_solver( use = {'useUmfpack' : True} )
>>> a = a.astype('D')
>>> x = spsolve(a, b)
>>> print x
>>> print "Error: ", a*x-b
>>>
>>> print "Solve: double precision:"
>>> a = a.astype('d')
>>> x = spsolve(a, b)
>>> print x
>>> print "Error: ", a*x-b
>>>
>>> print "Solve: single precision:"
>>> use_solver( use = {'useUmfpack' : False} )
>>> a = a.astype('f')
>>> x = spsolve(a, b.astype('f'))
>>> print x
>>> print "Error: ", a*x-b


"""
postpone_import = 1