Skip to content

Instantly share code, notes, and snippets.

@manvillej
Last active December 15, 2018 19:22
Show Gist options
  • Save manvillej/e89b0ccf7cf7af120bc5d2e395cab321 to your computer and use it in GitHub Desktop.
Save manvillej/e89b0ccf7cf7af120bc5d2e395cab321 to your computer and use it in GitHub Desktop.
>>> import numpy as np
>>> matrixA = np.matrix([
... [0, 0, 0, 0, 1, 0, 1, 0, 0, 0],
... [0, 0, 0, 0, 0, 0, 1, 0, 1, 0],
... [0, 0, 0, 0, 0, 0, 0, 1, 0, 1],
... [0, 0, 0, 0, 1, 0, 0, 0, 1, 0],
... [1, 0, 0, 1, 0, 0, 0, 0, 0, 0],
... [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
... [1, 1, 0, 0, 0, 0, 0, 1, 0, 0],
... [0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
... [0, 1, 0, 1, 0, 0, 0, 0, 0, 0],
... [0, 0, 1, 0, 1, 0, 0, 0, 0, 0]])
>>> matrixA
matrix([[0, 0, 0, 0, 1, 0, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 1, 0, 1],
[0, 0, 0, 0, 1, 0, 0, 0, 1, 0],
[1, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 1, 0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
[0, 1, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 1, 0, 0, 0, 0, 0]])
>>> matrixB = matrixA
>>> matrixC = matrixA*matrixB # The Matrix Multiplication bit
>>> matrixC
matrix([[2, 1, 0, 1, 0, 0, 0, 1, 0, 0],
[1, 2, 0, 1, 0, 0, 0, 1, 0, 0],
[0, 0, 2, 0, 1, 0, 1, 0, 0, 0],
[1, 1, 0, 2, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 2, 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],
[1, 1, 0, 0, 0, 0, 0, 2, 0, 1],
[0, 0, 0, 0, 1, 0, 1, 0, 2, 0],
[1, 0, 0, 1, 0, 0, 0, 1, 0, 1]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment