为什么 NumPy 没有引入 J 秩的概念?

2作者: jrank6 个月前
最近有一篇帖子 [1] 讨论了在使用形状大于 2 的数组时,numpy 并不容易使用的问题。<p><pre><code> [1] 中提到的一个问题是,你不能使用 Python 循环,因为它们很慢。在 J 语言中,你可以使用秩的概念来求解例如 100 个方程,这是一个简单的例子: a=: 2 2 $ 1 1 1 _1 b=: 10 2 $ ? 20 # 10 solutions =: b %. &quot;(1 _) a </code></pre> 这段代码求解了十个随机向量的方程组 a * v_i = b_i。我认为可以在 numpy 中开发一个类似的概念。语法 &quot;(1 _)&quot; 表示从左侧操作符中取出行,并对 a 的所有行(_ 代表无限)应用求解(在 J 语言中是 %.)。在这种情况下,方程组是 x+y=y0, x-y=y1。<p>因此,我建议类似 numpy.linalg.solve(a,b,rank=(1,inf)) 的用法<p>[1] https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=43996431
查看原文
Recently there was a post [1] about numpy being not easy to work with when using arrays of shape greater than 2.<p><pre><code> One of the problems mentioned in [1] is that you can not use python loops because they are slow. In J you can solve for example 100 equations using the rank concept, this is a simple example: a=: 2 2 $ 1 1 1 _1 b=: 10 2 $ ? 20 # 10 solutions =: b %. &quot;(1 _) a </code></pre> That code solve the systems a * v_i = b_i for ten random vectors. I think a similar concept could be developed in numpy. The syntax &quot;(1 _)&quot; indicates to take the rows from the left operator and all (_ is infinite) of a apply solve (that is %. in J). In this case the system is x+y=y0, x-y=y1.<p>So I would suggest somthing like numpy.linalg.solve(a,b,rank=(1,inf))<p>[1] https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=43996431