Issue #6852 has been updated by alexeymuranov (Alexey Muranov).


marcandre (Marc-Andre Lafortune) wrote:

> Oups, I was not thinking straight. [] corresponds to a 0x0 matrix (i.e. Matrix[] or Matrix.empty(0,0)). It is its own transpose.

Then it is not possible to express in the same way a 3 x 0 matrix (or 0 x 3?)  I think this was the reason for the original question.

I think it is not completely wrong to allow oneself for certain purposes, like for addition and multiplication, to identify matrices of different dimensions which can be obtained from one another by adding zeros, and also to identify all empty matrices.  The exact dimension is probably needed only for the determinant.

It is just a possible explanation for the current behavior.
----------------------------------------
Feature #6852: [].transpose should behave specially
https://bugs.ruby-lang.org/issues/6852#change-28772

Author: boris_stitnicky (Boris Stitnicky)
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 2.0.0


p = [1, 2, 3]
q = [4, 5, 6]
[p, q].transpose
# => [[1, 4], [2, 5], [3, 6]]
As expected, 2 x 3 vector was converted into 3 x 2.

[p].transpose
# => [[1], [2], [3]]
As expected, 1 x 3 => 3 x 1.

[].transpose
# => []
Unexpected, 0 x 3 did not become 3 x 0: [[], [], []]

In other words, when [] is the receiver, transpose has no way to know
what kind of ** 2 dimensional ** object is it - whether 0 x 3, 0 x 4, 0 x 1
or perhaps 0 x 0. #transpose should not assume it is 0 x 0. It should raise,
or warn, or complain, or require argument for this case, in short, it should
behave differently than today.


-- 
http://bugs.ruby-lang.org/