1

My question Regarding Python matrix. How to create a python matrix multiplication.

  1. For example, multiply 8 * 4 and 4 * 6?
Sanjay
  • 19
  • 2
  • 1
    Does this answer your question? [numpy matrix vector multiplication](https://stackoverflow.com/questions/21562986/numpy-matrix-vector-multiplication) – msamsami Oct 16 '22 at 06:15
  • Does this answer your question? [Difference between numpy dot() and Python 3.5+ matrix multiplication @](/q/34142485/90527), [how does multiplication differ for NumPy Matrix vs Array classes?](/q/3890621/90527) – outis Oct 16 '22 at 06:23
  • … [Matrix Multiplication in pure Python?](/a/47421436/90527) – outis Oct 16 '22 at 06:30

1 Answers1

0

You could use numpy library by using matmul(MatrixA,MatrixB) method.

In this method matmul you can pass two arguments "MatrixA" & "MatrixB" and it will multiply both matrixes together

Usage

import numpy as np

# Matrix A
A = [[2, 4],
      [6, 8]]

# Matrix B      
B = [[1, 3],
      [5, 7]]
 
"""
It will do the following:
A = [[2,4],[6,8]]
B = [[1,3],[5,7]]

After running the method
C = [[2*1, 4*3],[6*5, 8*7]] = [[2, 12],[30, 56]]
"""
print(np.matmul(A,B))

For more Information, you can head to this topic here

Nibras Shami
  • 144
  • 2
  • 14