Sage: Ticket #2429: block_matrix command should be consistent with the syntax of the matrix command
https://trac.sagemath.org/ticket/2429
<p>
The block matrix command uses a slightly different syntax than the matrix command, leading to confusion. It would be great to fix it so that the following examples would work. Assume that the xi variables below are matrices
</p>
<pre class="wiki">sage: # Throw an error if the dimensions of the blocks don't match up correctly.
sage: # explicitly specify the positions of the blocks
sage: block_matrix([[x1,x2],[x3,x4]])
sage: block_matrix([[x1,x2,x3],[x4,x5,x6]])
sage: # dimensions are the numbers of block rows and columns
sage: block_matrix(2,3, [x1,x2,x3,x4,x5,x6])
sage: # coerce the matrix to a specific ring
sage: block_matrix(QQ,2,3,[x1,x2,x3,x4,x5,x6])
sage: # 1 and 0 should still be interpreted as the identity and zero matrices
sage: block_matrix([[x1,1],[1,x2]])
sage: # if only one dimension is given, assume the matrix is square
sage: block_matrix(QQ,2,[x1,x2,x3,x4])
sage: block_matrix(2,[x1,x2,x3,x4])
sage: # the following works now
sage: block_matrix([x1,x2,x3,x4])
</pre>en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/2429
Trac 1.1.6jbmohlerTue, 11 Nov 2008 15:09:23 GMT
https://trac.sagemath.org/ticket/2429#comment:1
https://trac.sagemath.org/ticket/2429#comment:1
<p>
As commented in the original patch, the command
</p>
<pre class="wiki">sage: block_matrix([x1,x2,x3,x4])
</pre><p>
"works" where "works" means that it makes a 2x2 matrix of submatrices. While that was what I expected when I used the command, it is quite ambiguous and I felt like I was on shaky ground while writing my own code on top of it. I do not like the ambiguity of that.
</p>
<p>
Note that it is also inconsistent with the matrix command:
</p>
<pre class="wiki">sage: matrix([1,2,3,4])
[1 2 3 4]
</pre><p>
which makes a 1x4 matrix.
</p>
<p>
I'd say they should both make an 1xn matrix (or matrix of submatrices). Indeed, I'd almost rather that the syntax with a simple list and no explicit dimensions be banned outright when we don't know the dimensions from some parent object due to ambiguity. Seems to go along with "Explicit is better than implicit."
</p>
TicketwjpWed, 12 Jan 2011 01:48:23 GMTupstream set
https://trac.sagemath.org/ticket/2429#comment:2
https://trac.sagemath.org/ticket/2429#comment:2
<ul>
<li><strong>upstream</strong>
set to <em>N/A</em>
</li>
</ul>
<p>
There is now a patch at <a class="closed ticket" href="https://trac.sagemath.org/ticket/4492" title="defect: block_matrix reacts inconsistently with 0 (closed: fixed)">#4492</a> that handles this issue too.
</p>
TicketwjpWed, 16 Feb 2011 10:09:07 GMTcc, reviewer set
https://trac.sagemath.org/ticket/2429#comment:3
https://trac.sagemath.org/ticket/2429#comment:3
<ul>
<li><strong>cc</strong>
<em>jdemeyer</em> added
</li>
<li><strong>reviewer</strong>
set to <em>Willem Jan Palenstijn</em>
</li>
</ul>
<p>
Since ticket <a class="closed ticket" href="https://trac.sagemath.org/ticket/4492" title="defect: block_matrix reacts inconsistently with 0 (closed: fixed)">#4492</a> has been merged, this can now be closed too. Jeroen, could you do so?
</p>
TicketjdemeyerWed, 16 Feb 2011 10:36:07 GMTstatus, milestone changed; resolution set
https://trac.sagemath.org/ticket/2429#comment:4
https://trac.sagemath.org/ticket/2429#comment:4
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>duplicate</em>
</li>
<li><strong>milestone</strong>
changed from <em>sage-4.6.2</em> to <em>sage-duplicate/invalid/wontfix</em>
</li>
</ul>
Ticket