为什么 NumPy 没有复制 J 秩的概念?

2作者: jrank7 个月前原帖
最近有一篇帖子提到,当使用形状大于2的数组时,numpy的使用并不容易。[1]中提到的问题之一是,不能使用Python循环,因为它们速度较慢。在J语言中,可以通过秩的概念来解决例如100个方程,这是一个简单的例子: ``` a=: 2 2 $ 1 1 1 _1 b=: 10 2 $ ? 20 # 10 solutions =: b %. "(1 _) a ``` 这段代码解决了方程组 a * v_i = b_i,针对十个随机向量。我认为可以在numpy中开发类似的概念。语法“(1 _)”表示从左侧操作数中取行,并对a的所有行(_表示无限)应用求解(在J中是%.)。在这个例子中,系统是 x+y=y0,x-y=y1。 因此,我建议可以使用类似于 numpy.linalg.solve(a, b, rank=(1, inf)) 的语法。 [1] https://news.ycombinator.com/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