← Back
Editing: _special_matrices.cpython-311.pyc
� d�ct� � � � d dl Z d dlZd dlmZ g d�Zdd�Zdd�Zdd�Zdd�Z d� Z dd �Zefd �Z d� Zd� Zd � Zd� Zdd�Zd� Zdd�Zd d�Zd d�Zdd�Zd� Zd� Zd!d�ZdS )"� N)� as_strided)�tri�tril�triu�toeplitz� circulant�hankel�hadamard�leslie�kron� block_diag� companion�helmert�hilbert� invhilbert�pascal� invpascal�dft�fiedler�fiedler_companion�convolution_matrixc � � |�| }t |t � � r|}| }t j � t j || |z � � t j |� � � � }|�|S |� |� � S )a� Construct (N, M) matrix filled with ones at and below the kth diagonal. The matrix has A[i,j] == 1 for j <= i + k Parameters ---------- N : int The size of the first dimension of the matrix. M : int or None, optional The size of the second dimension of the matrix. If `M` is None, `M = N` is assumed. k : int, optional Number of subdiagonal below which matrix is filled with ones. `k` = 0 is the main diagonal, `k` < 0 subdiagonal and `k` > 0 superdiagonal. dtype : dtype, optional Data type of the matrix. Returns ------- tri : (N, M) ndarray Tri matrix. Examples -------- >>> from scipy.linalg import tri >>> tri(3, 5, 2, dtype=int) array([[1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 1, 1, 1, 1]]) >>> tri(3, 5, -1, dtype=int) array([[0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0]]) )� isinstance�str�np� greater_equal�outer�arange�astype)�N�M�k�dtype�ms �@/usr/lib/python3/dist-packages/scipy/linalg/_special_matrices.pyr r sw � �L �y� ���!�S��� � �� �� ����r�y��A�a�C�0�0�"�)�A�,�,�?�?�A��}����x�x����� c � � t j | � � } t | j d | j d || j j �� � | z }|S )a� Make a copy of a matrix with elements above the kth diagonal zeroed. Parameters ---------- m : array_like Matrix whose elements to return k : int, optional Diagonal above which to zero elements. `k` == 0 is the main diagonal, `k` < 0 subdiagonal and `k` > 0 superdiagonal. Returns ------- tril : ndarray Return is the same shape and type as `m`. Examples -------- >>> from scipy.linalg import tril >>> tril([[1,2,3],[4,5,6],[7,8,9],[10,11,12]], -1) array([[ 0, 0, 0], [ 4, 0, 0], [ 7, 8, 0], [10, 11, 12]]) r � )r"