a
    <b/                     @   sP   d dl mZ 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 )
    )check_assumptions)	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
    >>> from sympy import S, I, Matrix
    >>> 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sHtd|t| |||S )Nz {} should be an instance of Set.)r   
_check_dim
isinstancer   	TypeErrorformat__new__)clsnmset r   o/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-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rJtdd |j j D }|rFd 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>1       z&MatrixSet._contains.<locals>.<genexpr>Fc                 3   s   | ]} j |V  qd S r   )r   containsr   r   r   r   r   5   r    )r
   r   r   r   r   anyr   )r   otherZare_symbolicr   r   r   	_contains-   s    
zMatrixSet._containsc                 C   s(   t |ddd}|du r$td|dS )z2Helper function to check invalid matrix dimensionsT)integerZnonnegativeFz?The dimension specification {} should be a nonnegative integer.N)r   
ValueErrorr   )r   Zdimokr   r   r   r	   7   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.assumptionsr   Zsympy.core.logicr   Zsympy.core.sympifyr   Zsympy.sets.setsr   Zmatexprr   r   r   r   r   r   <module>   s
   