o
    8Va7                     @   sD   d dl mZ d dlmZ d dlmZ ddlmZ G dd deZdS )	    )	fuzzy_and)_sympify)Set   )
MatrixExprc                   @   sH   e Zd ZdZdZdd Zedd Zedd Zd	d
 Z	e
dd ZdS )	MatrixSetaw  
    MatrixSet represents the set of matrices with ``shape = (n, m)`` over the
    given set.

    Examples
    ========

    >>> from sympy.matrices import MatrixSet, Matrix
    >>> from sympy import S, I
    >>> M = MatrixSet(2, 2, set=S.Reals)
    >>> X = Matrix([[1, 2], [3, 4]])
    >>> X in M
    True
    >>> X = Matrix([[1, 2], [I, 4]])
    >>> X in M
    False

    Fc                 C   sX   t |t |t |}}}| | | | t|ts$td|t| |||S )Nz {} should be an instance of Set.)r   
_check_dim
isinstancer   	TypeErrorformat__new__)clsnmset r   A/usr/lib/python3/dist-packages/sympy/matrices/expressions/sets.pyr      s   


zMatrixSet.__new__c                 C   s   | j d d S N   argsselfr   r   r   shape$   s   zMatrixSet.shapec                 C   s
   | j d S r   r   r   r   r   r   r   (   s   
zMatrixSet.setc                    s`   t |tstd||j jkr%tdd |j j D }|r#d S dS t fdd|D S )Nz'{} should be an instance of MatrixExpr.c                 s   s    | ]}t |jV  qd S N)r   Z	is_Symbol.0xr   r   r   	<genexpr>0   s    z&MatrixSet._contains.<locals>.<genexpr>Fc                 3   s    | ]	} j |V  qd S r   )r   containsr   r   r   r   r   4   s    )r	   r   r
   r   r   anyr   )r   otherZare_symbolicr   r   r   	_contains,   s   
zMatrixSet._containsc                 C   s4   ddl m} ||ddd}|du rtd|dS )z2Helper function to check invalid matrix dimensionsr   )check_assumptionsT)ZintegerZnonnegativeFz?The dimension specification {} should be a nonnegative integer.N)Zsympy.core.assumptionsr#   
ValueErrorr   )r   Zdimr#   okr   r   r   r   6   s   zMatrixSet._check_dimN)__name__
__module____qualname____doc__Zis_emptyr   propertyr   r   r"   classmethodr   r   r   r   r   r      s    


r   N)	Zsympy.core.logicr   Zsympy.core.sympifyr   Zsympy.sets.setsr   Zmatexprr   r   r   r   r   r   <module>   s
    