{{indexmenu_n>999}} ====== Diagonal ====== ### Matrix.Diagonal($\{x_1,x_2,...,x_n\}$) takes a list of $n$ numbers and returns an $n \times n$ diagonal matrix with the $x_i$ as entries. If the option "Userdata" is set to true (default is false) the output is returned as a pointer rather than a table of tables (compare //[[documentation:language_reference:objects:matrix:functions:ToUserdata|Matrix.ToUserdata()]]//). ### ===== Example ===== ==== Input ==== xlist = {17,3,-4*I, sqrt(6)} M = Matrix.Diagonal(xlist) print(M) ==== Result ==== { { 17 , 0 , 0 , 0 } , { 0 , 3 , 0 , 0 } , { 0 , 0 , (-0 - 4 I) , 0 } , { 0 , 0 , 0 , 2.4494897427832 } } ===== Table of contents ===== {{indexmenu>.#1|msort}}