| #### D.3.1.3 diag Procedure from library `matrix.lib` (see matrix_lib). Usage: diag(p,n); p poly, n integer diag(A); A matrix Return: diag(p,n): diagonal matrix, p times unit matrix of size n. diag(A) : n*m x n*m diagonal matrix with entries all the entries of the nxm matrix A, taken from the 1st row, 2nd row etc of A Example:
    LIB "matrix.lib";
    ring r = 0,(x,y,z),ds;
    print(diag(xy,4));
    ==> xy,0, 0, 0,
    ==> 0, xy,0, 0,
    ==> 0, 0, xy,0,
    ==> 0, 0, 0, xy
    matrix A[3][2] = 1,2,3,4,5,6;
    print(A);
    ==> 1,2,
    ==> 3,4,
    ==> 5,6
    print(diag(A));
    ==> 1,0,0,0,0,0,
    ==> 0,2,0,0,0,0,
    ==> 0,0,3,0,0,0,
    ==> 0,0,0,4,0,0,
    ==> 0,0,0,0,5,0,
    ==> 0,0,0,0,0,6

User manual for Singular version 4.4.1, 2025, generated by texi2html.