#First 2D array
A = np.array ([
[1,2,3],
[4,5,6],
[7,8,9]
])
B = np.array ([
[6,5],
[4,3],
[2,1]
])
In python, there are many functions that are used for Linear Algebra. One of these functions is the dot Function. This function performs a dot function and it depends on the dimensions of A and B.
A.dot(B)
B.T
In python, the .T function stands for the transpose of the array. the transpose of the array means that it flips the array over its diagonal
We can combine this with the Matrix multiplication to allow for the same dimension Multiplication. This is done through the following :
B.T @ A #The @ symbol is used for Matrix Multiplication
When we deal with larger sets, we will have large amounts of data that if we do any operations on, we will want to see the performance. This can be the the time it took to compute, CPU times and so on.
%time sum(a ** 2)
%time sum[(x ** 2 for x in l])
%time sum(x ** 2 for x in l) # generator — recommended for big data
%time sum([x ** 2 for x in l]) # list — faster for small data