summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2020-04-30 18:04:30 -0400
committerMarc-Andre Lafortune <github@marc-andre.ca>2020-05-01 03:25:15 -0400
commit9b5675b325c9d4533e4f3db080cd2aa019068aad (patch)
treec0278d817deaeee8846574f46a026ba277ad3ebf /lib
parent07fd6dc49ba87ea2f0732851ec7628a526f3dcbd (diff)
[ruby/matrix] Add Matrix#adjoint [#14]
Patch adapted from Alessandro Minali
Diffstat (limited to 'lib')
-rw-r--r--lib/matrix.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb
index 75b5da29c7..336a92877b 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -1533,6 +1533,17 @@ class Matrix
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]]
# # => 1+2i i 0