This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import numpy as np | |
>>> # Scalars are just a single number. | |
>>> scalar = 5.0 | |
>>> np.isscalar(scalar) | |
True | |
>>> # Vectors are a matrix with one column. | |
>>> vector = np.arange(10) | |
>>> vector |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import numpy as np | |
>>> # Create a random matrix with 3 rows and 4 columns. | |
>>> matrix_a = np.random.random_sample((3, 4)) | |
>>> matrix_a | |
array([[ 0.21922347, 0.84313988, 0.41381942, 0.53553901], | |
[ 0.35322431, 0.38337327, 0.15964194, 0.30629508], | |
[ 0.16188791, 0.55971721, 0.33561351, 0.04709838]]) | |
>>> # Create a matrix from the transpose of A. Note the shapes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import numpy as np | |
>>> # Create a simple vector. | |
>>> vector = np.arange(3.) | |
>>> vector | |
array([ 0., 1., 2.]) | |
>>> # Create an identity with | |
>>> # the right dimensionality. | |
>>> identity = np.identity(3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import numpy as np | |
>>> # Create five vectors of size two to compute the norms for. | |
>>> values = np.array([[v, v] for v in np.arange(0.0, 1.0, 0.2)]) | |
>>> values | |
array([[ 0. , 0. ], | |
[ 0.2, 0.2], | |
[ 0.4, 0.4], | |
[ 0.6, 0.6], | |
[ 0.8, 0.8]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import numpy as np | |
>>> # Two vectors, a and b. | |
>>> a = np.array([-3, 4]) | |
>>> b = np.array([4, 3]) | |
>>> # The dot product is 0. | |
>>> a.dot(b) | |
0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import numpy as np | |
>>> # No scientific notation | |
>>> np.set_printoptions(suppress=True) | |
>>> # Some random orthogonal matrix. | |
>>> orthog = np.array([[-0.3639, 0.8268, 0.3570, 0.2377], | |
[-0.3578, -0.5330, 0.7427, 0.1906], | |
[-0.6208, -0.1798, -0.5609, 0.5174], | |
[-0.5951, 0.0024, -0.0797, -0.7997]]) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.