U
    Hvf                     @   sF   d Z ddlZddlmZmZ ddlmZ ddl	m
Z
 G dd dZdS )z3Test functions for linalg.matmul_toeplitz function
    N)toeplitzmatmul_toeplitz)raises)assert_allclosec                   @   s6   e Zd Zdd Zdd Zdd Zdd ZdddZd	S )TestMatmulToeplitzc                 C   s   t jd| _d| _d S )N*   g7QE=)nprandomZRandomStaterng	toleranceself r   K/tmp/pip-unpacked-wheel-96ln3f52/scipy/linalg/tests/test_matmul_toeplitz.pysetup_method   s    zTestMatmulToeplitz.setup_methodc                    s  g }d} j j|d} j j|d} j j|dfd}||||df d} j j|d} j j|d} j j|dfd}||||df d} j j|d} j j|d} j j|dfd}||||df d} j j|d} j j|d} j j|dfd}||||df d} j j|d} j j|d} j j| j dd	fd}||||df d} j j|dfd} j j|dfd} j j| j dd	fd}||||df d} j j|dfd}d } j j| j dd	fd}||||dd
f d} j j|dfd}d } j j|d}||||df d} j j|d} j j|d d} j j|d dfd}||||df d} j j|d} j j|d d} j j|d  j dd	fd}||||df  fdd|D  d S )N   sizeF   e   Ti  d   
         c                    s   g | ]} j | qS r   )do).0ir   r   r   
<listcomp>P   s     z0TestMatmulToeplitz.test_real.<locals>.<listcomp>)r
   normalappendrandint)r   Zcasesncrxr   r   r   	test_real   sh     zTestMatmulToeplitz.test_realc                 C   s,  d}| j j|dfd| j j|dfdd  }| j j|dfd| j j|dfdd  }| j j|dfd| j j|dfdd  }| |||d d}| j j|dfd| j j|dfdd  }| j j|d dfd| j j|d dfdd  }| j j|d dfd| j j|d dfdd  }| |||d d S )	N   r   r   y              ?   Fr   r   )r
   r   r   r   r"   r#   r$   r%   r   r   r   test_complexR   s    ((((zTestMatmulToeplitz.test_complexc                 C   s   d}| j j|d}| j jd| d}| j j|d}ttt||f|d d}| j j|d}| j j|d}| j j|d d}ttt||f|d d}| j j|d}| j j|d d}| j j|d d d}ttt||f|d d S )Nr   r   r   Tr   )r
   r   assert_raises
ValueErrorr   r)   r   r   r   test_exceptionsa   s    z"TestMatmulToeplitz.test_exceptionsNFc                 C   sN   |d krt ||||}nt ||f||}t||| }t||| j| jd d S )N)ZrtolZatol)r   r   r   r   )r   r%   r#   r$   Zcheck_finiteworkersactualZdesiredr   r   r   r   v   s     zTestMatmulToeplitz.do)NFN)__name__
__module____qualname__r   r&   r*   r-   r   r   r   r   r   r      s
   Ar   )__doc__Znumpyr   Zscipy.linalgr   r   Zpytestr   r+   Znumpy.testingr   r   r   r   r   r   <module>   s
   