Coverage for /usr/lib/python3/dist-packages/sympy/matrices/expressions/adjoint.py: 57%
28 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-14 15:55 +0200
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-14 15:55 +0200
1from sympy.core import Basic
2from sympy.functions import adjoint, conjugate
3from sympy.matrices.expressions.transpose import transpose
4from sympy.matrices.expressions.matexpr import MatrixExpr
7class Adjoint(MatrixExpr):
8 """
9 The Hermitian adjoint of a matrix expression.
11 This is a symbolic object that simply stores its argument without
12 evaluating it. To actually compute the adjoint, use the ``adjoint()``
13 function.
15 Examples
16 ========
18 >>> from sympy import MatrixSymbol, Adjoint, adjoint
19 >>> A = MatrixSymbol('A', 3, 5)
20 >>> B = MatrixSymbol('B', 5, 3)
21 >>> Adjoint(A*B)
22 Adjoint(A*B)
23 >>> adjoint(A*B)
24 Adjoint(B)*Adjoint(A)
25 >>> adjoint(A*B) == Adjoint(A*B)
26 False
27 >>> adjoint(A*B) == Adjoint(A*B).doit()
28 True
29 """
30 is_Adjoint = True
32 def doit(self, **hints):
33 arg = self.arg
34 if hints.get('deep', True) and isinstance(arg, Basic):
35 return adjoint(arg.doit(**hints))
36 else:
37 return adjoint(self.arg)
39 @property
40 def arg(self):
41 return self.args[0]
43 @property
44 def shape(self):
45 return self.arg.shape[::-1]
47 def _entry(self, i, j, **kwargs):
48 return conjugate(self.arg._entry(j, i, **kwargs))
50 def _eval_adjoint(self):
51 return self.arg
53 def _eval_conjugate(self):
54 return transpose(self.arg)
56 def _eval_trace(self):
57 from sympy.matrices.expressions.trace import Trace
58 return conjugate(Trace(self.arg))
60 def _eval_transpose(self):
61 return conjugate(self.arg)