Expand

Matrix.Expand($M$, $n$, $x$) takes a quadratic matrix $M$ of dimension $m$ by $m$ and enlarges the dimension by $n$ to $n+m$ by $n+m$. The new diagonal values are set to $x$. If $x$ is not given all new entries are set to 0.

Example

Input

Example.Quanty
A = Matrix.New({{1,2},
                {3,4}})
B = Matrix.Expand(A,4)
C = Matrix.Expand(A,4,3)
print(B)
print(C)

Result

{ {  1      ,  2      ,  0      ,  0      } ,
  {  3      ,  4      ,  0      ,  0      } ,
  {  0      ,  0      ,  0      ,  0      } ,
  {  0      ,  0      ,  0      ,  0      } }
 
{ {  1      ,  2      ,  0      ,  0      } ,
  {  3      ,  4      ,  0      ,  0      } ,
  {  0      ,  0      ,  3      ,  0      } ,
  {  0      ,  0      ,  0      ,  3      } }

Table of contents

Print/export