Since @kglr used the ToeplitzMatrix
, I thought it'd be a good idea to use the HankelMatrix
. Well, it was not but I managed to get the following
idm[n_] := IdentityMatrix[n]
hm[n_] := LowerTriangularize[Reverse@HankelMatrix[Range@n] + 1, -1]
diag[n_] :=
Diagonal[Map[Sort,
UpperTriangularize[Transpose@Reverse@HankelMatrix[n]], 1], #] & /@
Range[n - 1]
aux[n_] := Table[diag[n][[xx]] - (xx - 1), {xx, 1, n - 1}]
last[n_] := PadRight[ArrayPad[PadLeft[aux[n]], {0, {1, 0}}], {n, n}]
res[n_] := idm[n] + hm[n] + last[n]
We can check
Grid@Partition[MatrixForm /@ Table[res[i], {i, 2, 13}], 3]