Thanks! I did know Integer was an abstract type, it just didn't click til now that you should template out _all_ abstract types from type definitions.
Am I correct that there's no benefit of templating out method arguments? Since the compiler will compile every time it's called with a new concrete type? Also, when does the compiler know the return type of a method call? I gather never if it's an anonymous function, but I don't have a good intuition otherwise. Sent from my iPad > On 11 Jan 2014, at 6:36 am, Milan Bouchet-Valat <[email protected]> wrote: > >> Le vendredi 10 janvier 2014 à 13:36 -0500, Stefan Karpinski a écrit : >> You really want those to be colindex::Int and rowindex::Int – Integer is an >> abstract type, whereas Int is the concrete type of the native size integer >> (32/64 depending on your system). > Random suggestion of the day: how about renaming Integer to AbstractInt (or > anything else)? Else, be prepared to get many remarks like this over the > years, especially when less experienced people will start using Julia. > Integer is a very appealing name for somebody looking for the name of the > integer type... ;-) > > > Regards > > >>> On Fri, Jan 10, 2014 at 5:42 AM, Sheehan Olver <[email protected]> >>> wrote: >> Hi, >> I have the code below that wraps an array to allow non-standard index >> ranges, as part of an implementation of a linear algebra algorithm (Givens >> rotations). Surprisingly the setindex! routine is taking a significant >> portion of the computational cost, 30%, so I think I must not be getting the >> command to compile properly. Any hints? >> Cheers, >> Sheehan >> type ShiftArray{T<:Number} >> data::Array{T,2} >> colindex::Integer >> rowindex::Integer >> end >> Base.setindex!{T<:Number}(S::ShiftArray{T},x::T,k::Integer,j::Integer)=(S.data[k >> + S.rowindex, j + S.colindex] = x) >
