Hilfe bei Matrix multiplication
Verfasst: Donnerstag 3. Dezember 2020, 02:02
Kann mir jmd bei dem code hier helfen komme nicht weiter
import numpy as np
from lib import timedcall, plot_2d
def matrix_multiplication(a: np.ndarray, b: np.ndarray) -> np.ndarray:
"""
Calculate product of two matrices a * b.
Arguments:
a : first matrix
b : second matrix
Return:
c : matrix product a * b
Raised Exceptions:
ValueError: if matrix sizes are incompatible
Side Effects:
-
Forbidden: numpy.dot, numpy.matrix
"""
n, m_a = a.shape
m_b, p = b.shape
# TODO: test if shape of matrices is compatible and raise error if not
# Initialize result matrix with zeros
c = np.zeros((n, p))
# TODO: Compute matrix product without the usage of numpy.dot()
return c
import numpy as np
from lib import timedcall, plot_2d
def matrix_multiplication(a: np.ndarray, b: np.ndarray) -> np.ndarray:
"""
Calculate product of two matrices a * b.
Arguments:
a : first matrix
b : second matrix
Return:
c : matrix product a * b
Raised Exceptions:
ValueError: if matrix sizes are incompatible
Side Effects:
-
Forbidden: numpy.dot, numpy.matrix
"""
n, m_a = a.shape
m_b, p = b.shape
# TODO: test if shape of matrices is compatible and raise error if not
# Initialize result matrix with zeros
c = np.zeros((n, p))
# TODO: Compute matrix product without the usage of numpy.dot()
return c