I am newbie in julia, writing my first code! So, I apologize in advance if my question is a bit stupid.
It ran without any problems and did the expected.
Why are you using broadcasting S.(inputS,N) (note the dot) instead of a normal function call S(inputS, N)?
Oh ok, without the dot it works all fine.
I think i get it, so it’s because the way that i defined function S.
Since I’m already saying that x is an array it is not necessary to broadcasting S, it’s that right?
I could call with the dot? S.(inputS,N). Well I tried right now and gives me the BoundsError.
But you are presumably still doing x[i] > 0 etc in that function, but x is a Float.
Pretty much, yes. Broadcasting is a way to apply a scalar function across one or more arrays (or other collections). The function you broadcast can have any input types; the decision about whether to call f(x) or f.(x) is simply whether you want f to be called on the whole x or on each element of x.
It makes that kind of code more readable.