0

How can I multiply a matrix 4x4 by a vector 4x1 to get 4x1 using numpy?

Example:

Ax=b

Matrix A:

|   2    |    2   |   1   |   4   |
|   1    |   -3   |   2   |   3   |
|  -1    |    1   |  -1   |  -1   |
|   1    |   -1   |   1   |   2   |

Vector x:

|   1   |
|   0   |
|  -1   |
|   1   |

And get b:

|   5   |
|   2   |
|  -1   |
|   2   |

I've tried A*x.

I got a matrix 4x4 insted of a 4x1

juanpa.arrivillaga
  • 88,713
  • 10
  • 131
  • 172
  • 2
    Try `A @ x`, this is the correct operator for matrix multiplication. – ForceBru Apr 07 '23 at 09:04
  • As an aside, in the future, don't provide your own ad hoc representation of your data - you are using numpy, provide **code to create the appropriate example numpy arrays**. – juanpa.arrivillaga Apr 07 '23 at 09:06

0 Answers0