Complex#conj()是Complex類方法,它返回複數值極性形式的共軛部分。
用法:Complex.conj()
參數:複數值
返回:共軛部分的極值形式為複數。
示例1:
# Ruby code for Complex.conj() method
# declaring Complex value
a = Complex(200)
# declaring Complex value
b = Complex(-1, 4)
# declaring Complex value
c = Complex('i')
# use of conj()
puts "Complex conj form : #{a.conj}\n\n"
puts "Complex conj form : #{b.conj}\n\n"
puts "Complex conj form : #{c.conj}\n\n"
輸出:
Complex conj form : 200+0i Complex conj form : -1-4i Complex conj form : 0-1i
示例2:
# Ruby code for Complex.conj() method
# declaring Complex value
a = Complex(20, 90)
# declaring Complex value
b = Complex('i')
# declaring Complex value
c = Complex(100, -500)
# use of conj()
puts "Complex conj form : #{a.conj}\n\n"
puts "Complex conj form : #{b.conj}\n\n"
puts "Complex conj form : #{c.conj}\n\n"
輸出:
Complex conj form : 20-90i Complex conj form : 0-1i Complex conj form : 100+500i
注:本文由純淨天空篩選整理自 Ruby | Complex conj function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。