If I have some declared some Points in Julia (p_1,...,p_n). Is there some function or algorithm for kronecker delta (f_i(p_j)=1 if i=j and f_i(p_j)=0 if i != j)
It would be very helpful.
Thank you so much.
If you want a kronecker delta function you can use the ==(x,y) function (as indicated by @mbauman in the comments).
julia> δ(x,y) = ==(x,y)
δ (generic function with 1 method)
julia> δ(1,1)
true
julia> δ(1,2)
false
Note that this returns true or false instead of 1 and 0 but the former are essentially equal to the latter and will behave in the same way, for example ==(1,1) * 2 will give 2. In fact, true isa Integer in Julia.
Another option might be to use I the (lazy) identity matrix built into Julia (LinearAlgebra that is):
julia> using LinearAlgebra
julia> I[1,1]
true
julia> I[1,2]
false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With