I can't answer for the max/maximum case, but regarding dot notation for 
vector operations, it all quite makes sense if one tries to be as strict as 
possible with using actual mathematical notation. 

For example, having previously defined x = [0.1, 0.2, 0.3], then saying

x + 5

isn't really defined in a general sense. What you *might* mean by that is 
really x + 5 * [1, 1, 1], where 5 * [1, 1, 1] is interpreted as the regular 
vector-by-scalar multiplication. But this is not an operation that is 
required to define a general vector space - rather, a vector space is 
basically just a set V and a field F, with two operators defined:

+(v1, v2) is defined for v1, v2 in V yielding v3 = v1+v2
*(f,v) is defined for a *scalar *f in F and a vector v in V, such that w = 
f*v = v*f

An even more thorough definition is given 
here: http://en.wikipedia.org/wiki/Linear_algebra#Vector_spaces

In this context, it makes sense to have defined scalar multiplication and 
vector addition for x, but not define scalar addition - after all, it's a 
concept which is, in a strict mathematical sense, a little fuzzy. It's easy 
to define scalar addition once you consider *element-wise* operations, but 
that is exactly the distinction the dot notation is for - to make that 
distinction explicit. In your definition of the runge function, you're not 
actually working with a vector x in the mathematical sense of a vector 
space, but rather with an array as a container for many elements for which 
you want to perform the same calculations. Julia is really doing the same 
thing as e.g. Matlab here, but in a way that's less error-prone since it 
actually requires the user to decide whether it's an element-wise operation 
that is desired, or if it's really something else (and in that case, to 
better specify what else).

I hope this made some sense =)

// T



On Friday, May 2, 2014 3:55:20 PM UTC+2, Hans W Borchers wrote:
>
> I have to admit that I am quite unhappy with some of the changed features 
> in
> Julia version 0.3.0, especially the 'dot' notation. Here are some examples.
>
>
> Let x be a vector defined as  x = [0.1, 0.2, 0.3] . Then typing
>
>     julia> 5 + x
>     WARNING: x::Number + A::Array is deprecated, use x .+ A instead.
>
> but  5 + x  is a universal mathematical notation that should be allowed
> to be used regardless of any programming language considerations.
> On the other hand, both
>
>     julia> 5 * x;
>     julia> 5 .* x;
>
> work without warning. Why is  5 * x  not also deprecated?
>
> If I want to write, e.g., Runge's function in a vectorized form,
>
>     julia> runge(x) = 1 ./ (1 .+ 5.*x.^2)
>
> then this looks quite ugly and difficult to grasp on first view.
>
>
> As another example, look at the max / maximum 'dichotomy':
>
>     julia> maximum([x, 0.5])
>     0.5
>
>     julia> maximum(x, 0.5)
>     3-element Array{Float64,1}:
>      0.1
>      0.2
>      0.3
>
> The first answer looks natural, but I have difficulties understanding the
> meaning of the second case. On the other hand:
>
>     julia> max(x, 0.5)
>     3-element Array{Float64,1}:
>      0.5
>      0.5
>      0.5
>
> while  max(x, [0.5])  will lead to a dimension error, and  max([x, 0.5]) 
> to a deprecation warning (which I seem to understand why).
>
> I think all this is quite confusing for someone wanting to use Julia mostly
> for technical computing, as the logo promises.
> I am sure this has been discussed before, so probably I missed it. Sorry.
>
>

Reply via email to