Getting Started¶
This section provides some basic examples for using IMSL Library for Python (PyNL).
An Example Session¶
PyNL adheres to established conventions of the Python language. As such, familiarity with Python makes use of PyNL straightforward.
Using PyNL begins with importing the package that contains each function you are
using. For example, you can access the linear algebra function
lu_solve()
from the imsl.linalg
package
to use it to solve a linear system.
Below is an example using an interactive Python session.
>>> import imsl.linalg as la
>>> a = [[1.0, 3.0, 3.0], [1.0, 3.0, 4.0], [1.0, 4.0, 3.0]]
>>> b = [1.0, 4.0, -1.0]
>>> x = la.lu_solve(a, b)
>>> print(x)
[-2. -2. 3.]
An Example Script¶
PyNL can also be accessed from a non-interactive script by placing the commands into a file. For the above example, the following commands could be placed into a file named example.py
import imsl.linalg as la
a = [[1.0, 3.0, 3.0], [1.0, 3.0, 4.0], [1.0, 4.0, 3.0]]
b = [1.0, 4.0, -1.0]
x = la.lu_solve(a, b)
print(x)