Vishwa
Vishwa

Reputation: 55

How to create a matrix in python

Lets say I have a matrix: [1, 2, 3] & [4, 5, 6] & [7, 8, 9]. Written down they look like: this.

Now, I would like to create this matrix in Python, but I am not sure how to do so.

I think its written like either this:

import numpy as np
np.array([[1, 2, 3],
          [4, 5, 6],
          [7, 8, 9]])

Or like this:

import numpy as np
np.array([[1, 4, 7],
          [2, 5, 8],
          [3, 6, 9]])

Which way should I use?

Upvotes: 1

Views: 377

Answers (1)

Bruno Magacho
Bruno Magacho

Reputation: 115

Well, the right answer to this is that, there is none :)

Actually it all depends how do you want that this matrix acts on something.

Multiplying elementwise with another matrix, matrix product or matrix vector product.

Upvotes: 1

Related Questions