IDL#运算符的Python numpy等价物是什么?

IDL#运算符的Python numpy等价物是什么?,第1张

概述我正在寻找相当于 IDL#运算符的Python numpy. 这是 # operator的作用: Computes array elements by multiplying the columns of the first array by the rows of the second array. The second array must have the same number of co 我正在寻找相当于 IDL#运算符的Python numpy.
这是 # operator的作用:

Computes array elements 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 as 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.

这是我正在处理的numpy数组:

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

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

此外,numpy.dot(A,B)导致ValueError:矩阵未对齐.

解决方法 阅读有关IDL矩阵乘法定义的注释,似乎它们使用与其他所有人相反的符号:

IDL’s convention is to consIDer the first dimension to be the column
and the second dimension to be the row

所以#可以通过相当奇怪的外观来实现:

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

从他们的示例值:

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

[[ 3  4  5] [ 9 14 19] [15 24 33]]
总结

以上是内存溢出为你收集整理的IDL#运算符的Python numpy等价物是什么?全部内容,希望文章能够帮你解决IDL#运算符的Python numpy等价物是什么?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1197065.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存