pythonscipytoeplitz

toeplitz Matrix for a given N


For a given N, I need to create the following matrix: enter image description here

I have understood that :

 from scipy.linalg import toeplitz
 y=toeplitz(range(1,N))

will create a Toeplitz matrix. But it is not the exact matrix given above.
Appreciate your help


Solution

  • From the docs:

    scipy.linalg.toeplitz(c, r=None)

    Construct a Toeplitz matrix.

    The Toeplitz matrix has constant diagonals, with c as its first column and r as its first row. If r is not given, r == conjugate(c) is assumed.

    Thus you need to pass the first column and the first row like this:

    toeplitz(c=[1, *np.arange(N,1,-1)], r=np.arange(1,N+1))