What is the Python equivalent of the numpy IDL # operator?

I am looking for the Python equivalent of numpythe IDL # operator . Here is what # operator does :

Computes the elements of an array by multiplying the columns of the first array by the rows of the second array. The second array must have the same number of columns, since the first array has rows. The resulting array has the same number of columns as the first array, and the same number of rows as the second array.

Here are the arrays numpyI'm dealing with:

A = [[ 0.9826128   0.          0.18566662]
     [ 0.          1.          0.        ]
     [-0.18566662  0.          0.9826128 ]]

and

B = [[ 1.          0.          0.        ]
     [ 0.62692564  0.77418869  0.08715574]]

Also numpy.dot(A,B)leads to ValueError: matrices are not aligned.

+4
source share
2

IDL , , :

IDL -

, # :

numpy.dot(A.T, B.T).T

:

import numpy as np
A =  np.array([[0, 1, 2], [3, 4, 5]])
B = np.array([[0, 1], [2, 3], [4, 5]])
C = np.dot(A.T, B.T).T
print(C)

[[ 3  4  5]
 [ 9 14 19]
 [15 24 33]]
+1

, .

0

Source: https://habr.com/ru/post/1536915/


All Articles