Getting additive identity element in Julia – zero() Method
Last Updated :
01 Apr, 2020
The zero()
is an inbuilt function in julia which is used to return the additive identity element for the type of x, where x might also be type itself.
Syntax: zero(x)
Parameters:
Returns: It returns the additive identity element for the type of x, where x might also be type itself.
Example 1:
println(zero( 0 ))
println(zero( 1 ))
println(zero( 5.6 ))
println(zero(big "2.0" ))
|
Output:
Example 2:
println(zero(rand( 1 , 1 )))
println(zero(rand( 2 , 2 )))
println(zero(rand( 3 , 3 )))
|
Output:
[0.0]
[0.0 0.0; 0.0 0.0]
[0.0 0.0 0.0; 0.0 0.0 0.0; 0.0 0.0 0.0]
Share your thoughts in the comments
Please Login to comment...