from sage.matrix.constructor import matrix from sage.modules.free_module_element import vector from sage.functions.other import sqrt def _mat2vec(m): return vector(m.base_ring(), m.list())