diag函数的文档是这样说的
d=0 is the main diagonal.
d>0 is a diagonal from the lower half. For example, d=1 means the diagonal is set immediately below the main one.
d<0 is a diagonal from the upper half. For example, d=1 means the diagonal is set immediately above the main one.