Con la ayuda del Matrix().row_insert()
método, podemos insertar una fila en una array que tiene una dimensión nxm, donde la dimensión de la fila insertada es 1xm.
Sintaxis:
Matrix().row_insert()
Retorno: Retorna una nueva array.
Ejemplo #1:
En este ejemplo, podemos insertar una fila en una array usando el Matrix().row_insert()
método.
# Import all the methods from sympy from sympy import * # Make a matrix gfg_mat = Matrix([[1, 2], [2, 1]]) # use the row_insert() method for matrix new_mat = gfg_mat.row_insert(1, Matrix([[3, 4]])) print(new_mat)
Producción :
Array ([[1, 2], [3, 4], [2, 1]])
Ejemplo #2:
# Import all the methods from sympy from sympy import * # Make a matrix gfg_mat = Matrix([[1, 2], [2, 1]]) # use the row_insert() method for matrix new_mat = gfg_mat.row_insert(2, Matrix([[13, 24]])) print(new_mat)
Producción :
Array ([[1, 2], [2, 1], [13, 24]])
Publicación traducida automáticamente
Artículo escrito por Jitender_1998 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA