K i RdZddlmZmZmZddlmZddlmZddl m Z ddl m Z m Z mZGddZed ed d d ZeZej%d e ddgddggej%de ddgddggej%de ddgddggej%de ddgddggej%de ddgddggej%de ddgddggej%de de gedggej%de ddgdd ggej%de ddgdeggej%de ddgdeeezdz ggej%dee ddgdd ggzej%de ddgdd ggej%de gdgdgdgdgej%d ee ddgdd ggzej%d!e edgde ggy")#z7A cache for storing small matrices in multiple formats.)IRationalpi)Pow)exp)Matrix)to_sympyto_numpyto_scipy_sparsec<eZdZdZd dZdZdZdZdZdZ dZ y ) MatrixCacheaA cache for small matrices in different formats. This class takes small matrices in the standard ``sympy.Matrix`` format, and then converts these to both ``numpy.matrix`` and ``scipy.sparse.csr_matrix`` matrices. These matrices are then stored for future recovery. c i|_||_yN)_cachedtype)selfrs g/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/physics/quantum/matrixcache.py__init__zMatrixCache.__init__s  c |j|| |j|| |j||y#t$rY2wxYw#t$rY.wxYw#t$rYywxYw)zCache a matrix by its name. Parameters ---------- name : str A descriptive name for the matrix, like "identity2". m : list of lists The raw matrix data as a SymPy Matrix. N) _sympy_matrix ImportError _numpy_matrix_scipy_sparse_matrixrnamems r cache_matrixzMatrixCache.cache_matrixs{    tQ '    tQ '   % %dA .         s1;A A AA AA A%$A%ch|jj||f}||Std|d|d)aGet a cached matrix by name and format. Parameters ---------- name : str A descriptive name for the matrix, like "identity2". format : str The format desired ('sympy', 'numpy', 'scipy.sparse') zMatrix with name z and format z is not available.)rgetNotImplementedErrorrrformatrs r get_matrixzMatrixCache.get_matrix1s; KKOOT6N + =H! 6   rc&||j||f<yr)rr"s r _store_matrixzMatrixCache._store_matrixCs&' T6N#rc<|j|dt|y)Nsympy)r&r rs rrzMatrixCache._sympy_matrixFs 4(1+6rcXt||j}|j|d|y)Nrnumpy)r rr&rs rrzMatrixCache._numpy_matrixIs$ Qdjj ) 4!,rcXt||j}|j|d|y)Nr*z scipy.sparse)r rr&rs rrz MatrixCache._scipy_sparse_matrixMs& ATZZ 0 43rN)complex) __name__ __module__ __qualname____doc__rrr$r&rrrrrr r s*. $(7-4rr F)evaluateeye2op11op00op10op01XYZSTHHsqrt2SWAP)r7rrr)rrr7r)rr7rr)rrrr7ZXZYN)r1sympy.core.numbersrrrsympy.core.powerr&sympy.functions.elementary.exponentialrsympy.matrices.denser!sympy.physics.quantum.matrixutilsr r r r sqrt2_inv matrix_cacherr2rrrNsf=00 6' D4D4N 8B?U 3 } &&1a&1a&)9":; &&1a&1a&)9":; &&1a&1a&)9":; &&1a&1a&)9":; &&1a&1a&)9":; #v1v1v&678 #vA2wA&789 #v1v2w&789 #v1v1v&678 #v1v3qtAv;/?&@AB #y!Q!R0A)BBC (FQFQG+<$=>  FL, lK LN $ &1a&1b'1B*C CD $AQB'8 9:r