-
Notifications
You must be signed in to change notification settings - Fork 3
Numpy
NumPy is a package of modules for python that provides greater flexibility for arrays, linear algebra functions, and math. Since NumPy arrays are much easier to work with, they are often used in PINSPEC for the user to provide information to a function. Some commonly used formats and functions used in input files for NumPy arrays are given below.
Consider a basic matrix of the structure
A = [ 1. 2. 3.
4. 5. 6.
7. 8. 9.]
The numpy equivalent would be:
>>> A = numpy.array([[1.,2.,3.],[4.,5.,6.],[7.,8., 9.]])
To create an array full of zeros of size 1x2x3:
>>> X = numpy.zeros((1,2,3))
To use the previous commands and view the matrices created, the following commands can be invoked via interpreter or script:
import numpy
A = numpy.array([[1.,2.,3.],[4.,5.,6.],[7.,8., 9.]])
print A
X = numpy.zeros((1,2,3))
print X
For further guidance on NumPy, a reference manual for NumPy v1.7 can be found here. For users familiar with MATLAB, guidance on the transition to NumPy can be found here.