ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 11 Apr 2018 00:15:48 +0200Map a matrix to a block matrixhttps://ask.sagemath.org/question/41974/map-a-matrix-to-a-block-matrix/ Hello,
I have a function that maps an element $x$ into a $1\times n$ matrix, say for example $[x,x,x]$. I would like to map this function to a matrix and consider the resulting matrix as a "block matrix". E.g: change matrix([[1,2],[3,4]]) into matrix([[1,1,1,2,2,2],[3,3,3,4,4,4]]).
For now, I use a trick that basically converts back the matrix to a a list using something like:
block_matrix([[f(elt) for elt in row] for row in M.rows()])
but it looks quite dirty so I would like to know if there are some better way to proceed.
Thank you!tobiasBoraWed, 11 Apr 2018 00:15:48 +0200https://ask.sagemath.org/question/41974/