| Server IP : 93.86.61.54 / Your IP : 216.73.216.60 Web Server : Apache/2.4.62 (Ubuntu) System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64 User : www-data ( 33) PHP Version : 8.4.22 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/lib/python3/dist-packages/sympy/polys/matrices/__pycache__/ |
Upload File : |
o
�8VaΝ � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZm Z m
Z
mZmZm
Z
ddlmZ dd lmZ dd
lmZ ddlmZmZ G dd
� d
�ZdS )a�
Module for the DomainMatrix class.
A DomainMatrix represents a matrix with elements that are in a particular
Domain. Each DomainMatrix internally wraps a DDM which is used for the
lower-level operations. The idea is that the DomainMatrix class provides the
convenience routines for converting between Expr and the poly domains as well
as unifying matrices with different domains.
� )�reduce��_sympify� ��construct_domain� )�NonSquareMatrixError�
ShapeError�
DDMShapeError�DDMDomainError�DDMFormatError�DDMBadInputError)�DDM)�SDM)�DomainScalar)�ZZ�EXRAWc sn e Zd ZdZdd�dd�Zdd� Zdd � Zd
d� Zdd
� Zdd� Z e
� fdd��Ze
dd� �Ze
dd� �Z
e
d�dd��Ze
dd� �Zdd� Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Ze
d'd(� �Ze
dd�d)d*��Zdd�d+d,�Zd-d.� Zd/d0� Zd1d2� Zd3d4� Zd5d6� Zd7d8� Zd9d:� Ze d;d<� �Z!d=d>� Z"d?d@� Z#d�dAdB�Z$dCdD� Z%dEdF� Z&dGdH� Z'dIdJ� Z(dKdL� Z)dMdN� Z*dOdP� Z+dQdR� Z,dSdT� Z-dUdV� Z.dWdX� Z/dYdZ� Z0d[d\� Z1d]d^� Z2d_d`� Z3dadb� Z4dcdd� Z5dedf� Z6dgdh� Z7didj� Z8dkdl� Z9dmdn� Z:dodp� Z;dqdr� Z<dsdt� Z=dudv� Z>dwdx� Z?dydz� Z@e
d{d|� �ZAe
d�d}d~��ZBe
dd�dd���ZCe
d�d�� �ZDd�d�� ZEd�d�� ZF� ZGS )��DomainMatrixa�
Associate Matrix with :py:class:`~.Domain`
Explanation
===========
DomainMatrix uses :py:class:`~.Domain` for its internal representation
which makes it more faster for many common operations
than current sympy Matrix class, but this advantage makes it not
entirely compatible with Matrix.
DomainMatrix could be found analogous to numpy arrays with "dtype".
In the DomainMatrix, each matrix has a domain such as :ref:`ZZ`
or :ref:`QQ(a)`.
Examples
========
Creating a DomainMatrix from the existing Matrix class:
>>> from sympy import Matrix
>>> from sympy.polys.matrices import DomainMatrix
>>> Matrix1 = Matrix([
... [1, 2],
... [3, 4]])
>>> A = DomainMatrix.from_Matrix(Matrix1)
>>> A
DomainMatrix({0: {0: 1, 1: 2}, 1: {0: 3, 1: 4}}, (2, 2), ZZ)
Driectly forming a DomainMatrix:
>>> from sympy import ZZ
>>> from sympy.polys.matrices import DomainMatrix
>>> A = DomainMatrix([
... [ZZ(1), ZZ(2)],
... [ZZ(3), ZZ(4)]], (2, 2), ZZ)
>>> A
DomainMatrix([[1, 2], [3, 4]], (2, 2), ZZ)
See Also
========
DDM
SDM
Domain
Poly
N��fmtc C s� t |ttf�rtd��t |t�rt|||�}nt |t�r#t|||�}nd}t|��|durC|dkr6|�� }n
|dkr?|�� }ntd��| � |�S )a�
Creates a :py:class:`~.DomainMatrix`.
Parameters
==========
rows : Represents elements of DomainMatrix as list of lists
shape : Represents dimension of DomainMatrix
domain : Represents :py:class:`~.Domain` of DomainMatrix
Raises
======
TypeError
If any of rows, shape and domain are not provided
z'Use from_rep to initialise from SDM/DDMz.Input should be list-of-lists or dict-of-dictsN�sparse�dense�!fmt should be 'sparse' or 'dense')
�
isinstancer r � TypeError�list�dict�to_sdm�to_ddm�
ValueError�from_rep)�cls�rows�shape�domainr �rep�msg� r( �C/usr/lib/python3/dist-packages/sympy/polys/matrices/domainmatrix.py�__new__N s
zDomainMatrix.__new__c C s@ | j }t|t�r
t|�}nt|t�rt|�}nt�|| j| jfS �N) r&