K i dZddlmZddlmZddlmZddlmZddl m Z m Z ddl m Z gdZe d Zes Gd d Zn ej"Ze d d dgiZes GddZdZnej(Zej*ZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&d$Z'd%Z(d&Z)d'Z*d(Z+y))z  QZF '&' Mrctst|d}|ddD]}tj||}tj|S)z=scipy.sparse version of tensor product of multiple arguments.rrCN)r$r-rQr9rRs r _scipy_sparse_tensor_productrXsL  QZF +VT*+   V $$rct|dtrt|St|dtrt |St|dt rt |Sy)zGCompute the matrix tensor product of sympy/numpy/scipy.sparse matrices.rN)r/rrOr rVr rX)rSs r rrsS'!*j)$g.. GAJ .$g.. GAJ 3 4+W55 5rcntsttjtj|dS)znumpy version of complex eye.r*r+)r,r-r0rns r _numpy_eyer]s'  88BFF1IF. //rcJtsttj||dS)z$scipy.sparse version of complex eye.r*r+)r$r-rr[s r _scipy_sparse_eyer_s  ::a): ,,rc |jdd}|dk(r t|S|dk(r t|S|dk(r t|St d|z)z=Get the version of eye and tensor_product for a given format.formatsympyr scipy.sparsezInvalid format: %r)r.rr]r_NotImplementedError)r\r7ras r matrix_eyeresY [[7 +F 1v 7 !} > ! ## 2V; < !"1a3733 2V; <rsB "0%( &7   JJMgj8*-EF   F \\F // J J#  M M M M/ %60- =) 6 =   r