Skip to content

make diagonal_matrix accept much more general arguments #3704

@sagetrac-jkantor

Description

@sagetrac-jkantor

So I think this is a bug

sage: w=vector(RR,[1,2,3])
sage: d=diagonal_matrix(w)
UnboundLocalError: local variable 'v' referenced before assignment

The following fails as well

sage: d=diagonal_matrix(RR,w) 

the only thing that works is

sage: d=diagonal_matrix(RR,list(w))

A stupid but easy fix is to try to turn any argument to diagonal_matrix into a list before bailing out (its in matrix/constructor.py), but there should probably be logic actually expecting vectors and analyzing the parents?

Component: linear algebra

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions