<s> from __future__ import print_function , division <EOL> from sympy . core . sympify import _sympify <EOL> from sympy . core import S , Basic <EOL> from sympy . matrices . expressions . matexpr import ShapeError <EOL> from sympy . matrices . expressions . matpow import MatPow <EOL> class Inverse ( MatPow ) : <EOL> """<STR_LIT>""" <EOL> is_Inverse = True <EOL> exp = S ( - <NUM_LIT:1> ) <EOL> def __new__ ( cls , mat ) : <EOL> mat = _sympify ( mat ) <EOL> if not mat . is_Matrix : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> if not mat . is_square : <EOL> raise ShapeError ( "<STR_LIT>" % mat ) <EOL> return Basic . __new__ ( cls , mat ) <EOL> @ property <EOL> def arg ( self ) : <EOL> return self . args [ <NUM_LIT:0> ] <EOL> @ property <EOL> def shape ( self ) : <EOL> return self . arg . shape <EOL> def _eval_inverse ( self ) : <EOL> return self . arg <EOL> def _eval_determinant ( self ) : <EOL> from sympy . matrices . expressions . determinant import det <EOL> return <NUM_LIT:1> / det ( self . arg ) <EOL> def doit ( self , ** hints ) : <EOL> if hints . get ( '<STR_LIT>' , True ) : <EOL> return self . arg . doit ( ** hints ) . inverse ( ) <EOL> else : <EOL> return self . arg . inverse ( ) <EOL> from sympy . assumptions . ask import ask , Q <EOL> from sympy . assumptions . refine import handlers_dict <EOL> def refine_Inverse ( expr , assumptions ) : <EOL> """<STR_LIT>""" <EOL> if ask ( Q . orthogonal ( expr ) , assumptions ) : <EOL> return expr . arg . T <EOL> elif ask ( Q . unitary ( expr ) , assumptions ) : <EOL> return expr . arg . conjugate ( ) <EOL> elif ask ( Q . singular ( expr ) , assumptions ) : <EOL> raise ValueError ( "<STR_LIT>" % expr . arg ) <EOL> return expr <EOL> handlers_dict [ '<STR_LIT>' ] = refine_Inverse </s>
