Last active
October 23, 2018 13:10
-
-
Save manvillej/1478d72656c06feeeabd0e2fad75b3a4 to your computer and use it in GitHub Desktop.
summing a row in a matrix.
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
>>> matrix | |
matrix([[ 2., 0., 1., 0., 0., 0., 1., 0., 0., 1.], | |
[ 0., 2., 0., 1., 0., 1., 0., 0., 0., 0.], | |
[ 1., 0., 2., 0., 0., 0., 0., 0., 1., 1.], | |
[ 0., 1., 0., 3., 0., 1., 0., 1., 0., 0.], | |
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], | |
[ 0., 1., 0., 1., 0., 3., 0., 1., 0., 0.], | |
[ 1., 0., 0., 0., 0., 0., 2., 0., 1., 1.], | |
[ 0., 0., 0., 1., 0., 1., 0., 2., 0., 0.], | |
[ 0., 0., 1., 0., 0., 0., 1., 0., 2., 1.], | |
[ 1., 0., 1., 0., 0., 0., 1., 0., 1., 2.]]) | |
>>> np.sum(matrix[0]) # 0 would be the starting position | |
5.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment