From 9b5675b325c9d4533e4f3db080cd2aa019068aad Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Thu, 30 Apr 2020 18:04:30 -0400 Subject: [ruby/matrix] Add Matrix#adjoint [#14] Patch adapted from Alessandro Minali --- lib/matrix.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib') diff --git a/lib/matrix.rb b/lib/matrix.rb index 75b5da29c7..336a92877b 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -1532,6 +1532,17 @@ class Matrix end alias_method :conj, :conjugate + # + # Returns the adjoint of the matrix. + # + # Matrix[ [i,1],[2,-i] ].adjoint + # # => -i 2 + # # 1 i + # + def adjoint + conjugate.transpose + end + # # Returns the imaginary part of the matrix. # Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]] -- cgit v1.2.3