Project

General

Profile

Feature #10058 » reorder_Matrix#real_and_Matrix_imaginary.patch

gogotanaka (Kazuki Tanaka), 07/18/2014 08:11 AM

View differences:

lib/matrix.rb
alias conj conjugate
#
# Returns the imaginary part of the matrix.
# Returns the real part of the matrix.
# Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]]
# => 1+2i i 0
# 1 2 3
# Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].imaginary
# => 2i i 0
# 0 0 0
# Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].real
# => 1 0 0
# 1 2 3
#
def imaginary
collect(&:imaginary)
def real
collect(&:real)
end
alias imag imaginary
#
# Returns the real part of the matrix.
# Returns the imaginary part of the matrix.
# Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]]
# => 1+2i i 0
# 1 2 3
# Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].real
# => 1 0 0
# 1 2 3
# Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].imaginary
# => 2i i 0
# 0 0 0
#
def real
collect(&:real)
def imaginary
collect(&:imaginary)
end
alias imag imaginary
#
# Returns an array containing matrices corresponding to the real and imaginary
(2-2/3)