FUNCTION DIAG,v,n ;+ ;A=diag(v) constructs a diagonal matrix with the vector ;v as the diagonal. ; ;A=diag(v,n) constructs a diagonal matrix of size nxn ;using the first n elements of v if nn_elements(v). ; ;Note: Kept for old programs. It is better to use the built-in ;DIAG_MATRIX program in IDL. ; ;Harvey Rhody ;May 18, 2002 ;- nv=n_elements(v) IF n_params() LT 2 THEN n=nv type=Size(V,/type) A=Make_Array(n,n,TYPE=type) nd=n