3 ms·
So does Matlab/Octave and R, so Julia's choice is unsurprising to many people in the target demographic.
by computerphage 8y ago
So does Matlab/Octave and R, so Julia's choice is unsurprising to many people in the target demographic.
- jordigh 8y agoAnd Matlab and Octave in turn inherited it from Fortran, which inherited it from classical numerical analysis. One-based indexing has a good, long history.
- creativeembassy 8y agoTo use a silly example... can I finally realize my dream of two-based indexing?
- ChrisRackauckas 8y agoYes. And 1.5-based indexing, though I would recommend using rational numbers instead of floating point numbers for this one.
- JulianMorrison 8y agoAnd imaginary is right out.
- stabbles 8y agoMaybe you could use complex numbers to index matrices
- 3JPLW 8y agoSure can: # Magic julia> Base.to_indices(A, inds, I::Tuple{Complex, Vararg{Any}}) = (real(I[1]), imag(I[1]), to_indices(A, Base._maybetail(Base._maybetail(inds)), Base.tail(I))...) julia> A 4×5 reshape(::UnitRange{Int64}, 4, 5) with eltype Int64: 1 5 9 13 17 2 6 10 14 18 3 7 11 15 19 4 8 12 16 20 julia> A[3 + 2im] 7 ```
- ChrisRackauckas 8y agoAnd quaternions for image stacks in ML? Troll, but not too troll...
- elcritch 8y agoThat’s a right kind of wrong... and could work with FEA tensor too... ;)
- jordigh 8y agoStory time! When Octave was getting a lot of traffic from the first Coursera machine learning class, when it was just Andrew Ng doing a course and before the Coursera org existed, we were getting a lot of novice users who would do something like some_matrix(i,j) = 5 and get cryptic errors about how matrices cannot be indexed by complex numbers. This is because by default, in Matlab and Octave `i` and `j` are functions that evaluate to the imaginary unit. You have to overwrite the function names with `i=2, j=3` or whatever beforehand, which novices often forget. This was happening often enough that I pushed some patches to warn, "did you forget to assign i or j?" if someone tried to index matrices with complex numbers. Point is, people in Matlab and Octave often unintentionally try to index by complex numbers.