but 5 + x is a universal mathematical notation that should be allowedto be used regardless of any programming language considerations
x = [1 2;
2 3]
row = [3 4]
x + row # this correctly gives an error
x .+ row # julia knows I want `row` broadcasted
A_clamped = min(A, 1)
A_col_minima = minimum(A, 1)
min(A,1) => smallest value of A or 1, whichever is smallermin(A,1, dim=()) => same shape as A, clamped above at 1min(A,1, dim=1) => the minimum of each column or 1 as a row matrixmin(A,1, dim=2) => the minimum of each row or 1 as a column matrix
BTW: I like maxof better than pmax, but maybe like .max() better than either ;)
yeah, I can imagine how annoying it is to the developers that all us newbies feel like we can chime in on language design:) However, I do think its a sign of how natural and inclusive the language feels to the everyday user.
BTW: I like maxof better than pmax, but maybe like .max() better than either ;)
K leo, I think it's mainly a problem of consistency across operators (+ behave like * and .+ behave like .*) and across dimensions (adding a scalar to a vector behave the same as adding a vector to a matrix).
The nice thing with Julia is that you can easily (re) define operators to do what you want, if you prefer + to work with scalar you can just define:
+{T,K}(a::Array{T,K},x::Number) = a .+ x
And it should work.
julia> x = [0.1, 0.2, 0.3];
julia> 5 + x
3-element Array{Float64,1}:
5.1
5.2
5.3
julia> versioninfo()
Julia Version 0.3.0-prerelease+3921
Commit 0b46af5* (2014-06-28 02:01 UTC)
Platform Info:
System: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz
WORD_SIZE: 64
BLAS: libblas.so.3
LAPACK: liblapack.so.3
LIBM: libopenlibm
I have to admit that I am quite unhappy with some of the changed features inJulia 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
What has happened, two months later, to the (in)famous 'dot' notation in Julia?
There was such a convincing discussion that 5 + x shall not be correct, so
I got used to it. When I now by chance try ...