Top
Back: D.3.1.2 concat
Forward: D.3.1.4 dsum
FastBack: D. SINGULAR libraries
FastForward: E. Release Notes
Up: D.3.1 matrix_lib
Top: Singular 2-0-4 Manual
Contents: Table of Contents
Index: F. Index
About: About This Document

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 

Top Back: D.3.1.2 concat Forward: D.3.1.4 dsum FastBack: D. SINGULAR libraries FastForward: E. Release Notes Up: D.3.1 matrix_lib Top: Singular 2-0-4 Manual Contents: Table of Contents Index: F. Index About: About This Document
            User manual for Singular version 2-0-4, October 2002, generated by texi2html.