Skip to content

block_matrix reacts inconsistently with 0 #4492

@sagetrac-jbmohler

Description

@sagetrac-jbmohler

Using ZZ(0) as an element of the list passed to block_matrix appears to be a special case somehow and throws an exception rather than creating the matrix seems reasonable to me.

sage: i=MatrixSpace(ZZ,2,2)(1)
sage: i

[1 0]
[0 1]
sage: block_matrix([1,i,1,1])  # this works as I expect

[1 0|1 0]
[0 1|0 1]
[---+---]
[1 0|1 0]
[0 1|0 1]
sage: block_matrix([0,i,1,1])  # this doesn't ... why is 0 special
...
ValueError: Insufficient information to determine dimensions.

This feels to me like a hazardous inconsistency.

Perhaps I should also add that I don't really like that it just blithely assumes I want a square matrix (although I did in my actual usage). Ticket #2429 addresses that issue more wholeheartedly.

Apply:

  1. attachment: 4492_block_matrix_rebased.patch
  2. attachment: trac_4492-block-matrix-reviewer.patch
  3. attachment: 4492_typo.patch
  4. attachment: trac_4492-doctest-number-field.patch

CC: @craigcitro @jasongrout @loefflerd

Component: linear algebra

Author: Willem Jan Palenstijn

Reviewer: Aly Deines, Rob Beezer

Merged: sage-4.6.2.alpha3

Issue created by migration from https://trac.sagemath.org/ticket/4492

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions