Numpy contains core routines for doing fast vector, matrix, and linear algebra-type operations in Python.
In [1]:
from numpy import *
In [2]:
array([1, 2, 3])
Out[2]:
In [4]:
array([[0,1],[1,0]], 'f')
Out[4]:
In [7]:
zeros((2, 3))
Out[7]:
In [8]:
identity(4)
Out[8]:
In [3]:
a = array([[0, 1, 2],[3, 4, 5]])
a
Out[3]:
In [4]:
a[0][0]
Out[4]:
In [5]:
a[0, 0]
Out[5]:
In [6]:
a[-1, 0]
Out[6]:
In [9]:
a[:, 1]
Out[9]:
In [8]:
a[0, :-1]
Out[8]:
In [10]:
0.5 * identity(2)
Out[10]:
In [11]:
identity(2) * 0.3 + array([[1, 0], [0, 0]])
Out[11]:
In [13]:
a0 = random.random((3,3))
a1 = random.random((3,3))
In [27]:
a0
Out[27]:
In [28]:
a1
Out[28]:
In [29]:
a0 * a1
Out[29]:
In [30]:
a0.dot(a1)
Out[30]:
In [31]:
dot(a0, a1)
Out[31]:
In [32]:
a0.T
Out[32]:
In [15]:
linalg.pinv(a0).dot(a0)
Out[15]: