Ruby 矩阵 conj() 函数
conj() 是Ruby中一个内置的方法,用于返回共轭矩阵。
语法 :mat1.conj()
参数 :该函数不接受任何参数。
返回值 : 它返回共轭矩阵。
例子 1 :
# Ruby program for conj() method in Matrix
# Include matrix
require "matrix"
# Initialize a matrix
mat1 = mat1 = Matrix[[1, Complex(2, 1)], [Complex(8, -9), 18]]
# prints the conjugate matrix
puts mat1.conj()
输出:
Matrix[[1, 2-1i], [8+9i, 18]]
例2 :
# Ruby program for conj() method in Matrix
# Include matrix
require "matrix"
# Initialize a matrix
mat1 = Matrix[[Complex(2, 5), 1, 5], [Complex(12, 1), 1, 5],
[11, 2, Complex(6, -1)]]
# prints the conjugate matrix
puts mat1.conj()
输出:
Matrix[[2-5i, 1, 5], [12-1i, 1, 5], [11, 2, 6+1i]]