julia矩阵运算
Julia| 复数 (Julia | Complex Numbers)
The syntax to represent the complex number in Julia is:
在Julia中表示复数的语法为:
Syntax:
句法:
A+Bim
Here, A and B are the values, and im is the global constant which is bound to the complex number i representing the principal square root of -1.
这里, A和B是值, im是全局常数,该常数绑定到表示-1的主平方根的复数i上 。
Example 1:
范例1:
# Julia program to demonstrate the example
# of complex numbers and operations on it
println(1+2im)
println((1+2im)+(2+4im))
# variables
x = 10+23im
println("x: ", x)
println("typeof(x): ", typeof(x))
Output
输出量
1 + 2im
3 + 6im
x: 10 + 23im
typeof(x): Complex{Int64}
复数的各种运算 (Various operations on Complex Numbers)
Example 2:
范例2:
# Julia program to demonstrate the example
# of complex numbers and operations on it
x = 1+2im
y = 2.34+78.909im
println("x: ", x)
println("y: ", y)
# operations
add = x+y
sub = x-y
mul = x*y
div = x/y
exp = x^2
# printing
println("add: ", add)
println("sub: ", sub)
println("mul: ", mul)
println("div: ", div)
println("exp: ", exp)
Output
输出量
x: 1 + 2im
y: 2.34 + 78.909im
add: 3.34 + 80.909im
sub: -1.3399999999999999 - 76.909im
mul: -155.478 + 83.589im
div: 0.02569885734584168 - 0.011910741155137315im
exp: -3 + 4im
Reference: Julia Complex Numbers
参考: Julia复数
翻译自: https://www.includehelp.com/julia/complex-numbers-and-operations.aspx
julia矩阵运算