diff --git a/.mailmap b/.mailmap index 772ea455a0f2d..b8339614e4c57 100644 --- a/.mailmap +++ b/.mailmap @@ -34,7 +34,7 @@ Stephan Boyer Stephan Boyer Jiahao Chen Jiahao Chen (陈家豪) - + Giuseppe Zingales Giuseppe Zingales @@ -100,17 +100,17 @@ Steven G. Johnson Steven G. Johnson Isaiah Norton -Isaiah Norton +Isaiah Norton Blake Johnson Blake Johnson Marcus Silva -Marcus Silva +Marcus Silva Amit Murthy -Tanmay Mohapatra +Tanmay Mohapatra Tanmay Mohapatra Dan Luu @@ -119,10 +119,10 @@ Dan Luu Kevin Bache Kevin Bache -Rick +Rick Rick -David Smith +David Smith David Smith Carlos Becker @@ -138,16 +138,16 @@ Joseph Perla Jutho Tomas Lycken - -Simon Byrne -Simon Byrne -Jake Bolewski +Simon Byrne +Simon Byrne + +Jake Bolewski Leah Hanson -Lei Wang -Lei Wang +Lei Wang +Lei Wang Kevin Squire diff --git a/.travis.yml b/.travis.yml index 1abd9c1b406cb..0e03213a86e60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,7 @@ before_install: make $BUILDOPTS -C contrib -f repackage_system_suitesparse4.make; fi script: + - ! git grep ' $' -- \*.jl \*.scm \*.c \*.cpp \*.h > /dev/null || { echo "trailing whitespace found in source file"; exit 1; } - make $BUILDOPTS prefix=/tmp/julia install - if [ `uname` = "Darwin" ]; then for name in spqr umfpack colamd cholmod amd suitesparse_wrapper; do diff --git a/base/Dates.jl b/base/Dates.jl index bcc7692299be3..53b2cb66c9f81 100644 --- a/base/Dates.jl +++ b/base/Dates.jl @@ -26,7 +26,7 @@ export Period, DatePeriod, TimePeriod, July, August, September, October, November, December, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, # conversions.jl - unix2datetime, datetime2unix, now, today, + unix2datetime, datetime2unix, now, today, rata2datetime, datetime2rata, julian2datetime, datetime2julian, # adjusters.jl firstdayofweek, lastdayofweek, diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 64f7966985184..98574dd2cb22c 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -323,12 +323,12 @@ float{T<:Integer64}(x::AbstractArray{T}) = convert(AbstractArray{typeof(float(ze complex{T<:Union(Integer64,Float64,Float32,Float16)}(x::AbstractArray{T}) = convert(AbstractArray{typeof(complex(zero(T)))}, x) -function float(A::AbstractArray) +function float(A::AbstractArray) cnv(x) = convert(FloatingPoint,x) map_promote(cnv, A) end -function complex(A::AbstractArray) +function complex(A::AbstractArray) cnv(x) = convert(Complex,x) map_promote(cnv, A) end @@ -609,7 +609,7 @@ function cat(catdims, X...) for k = 1:length(catdims) dims2cat[catdims[k]]=k end - + typeC = isa(X[1],AbstractArray) ? eltype(X[1]) : typeof(X[1]) dimsC = Int[d <= ndimsX[1] ? size(X[1],d) : 1 for d=1:ndimsC] for k = 1:length(catdims) @@ -627,12 +627,12 @@ function cat(catdims, X...) end end end - + C = similar(isa(X[1],AbstractArray) ? full(X[1]) : [X[1]], typeC, tuple(dimsC...)) if length(catdims)>1 fill!(C,0) end - + offsets = zeros(Int,length(catdims)) for i=1:nargs cat_one = [ dims2cat[d]==0 ? (1:dimsC[d]) : (offsets[dims2cat[d]]+(1:catsizes[i,dims2cat[d]])) for d=1:ndimsC] @@ -1378,7 +1378,7 @@ function randsubseq!(S::AbstractArray, A::AbstractArray, p::Real) end else # Skip through A, in order, from each element i to the next element i+s - # included in S. The probability that the next included element is + # included in S. The probability that the next included element is # s==k (k > 0) is (1-p)^(k-1) * p, and hence the probability (CDF) that # s is in {1,...,k} is 1-(1-p)^k = F(k). Thus, we can draw the skip s # from this probability distribution via the discrete inverse-transform diff --git a/base/array.jl b/base/array.jl index fb6ec5287888b..01f561fad6db7 100644 --- a/base/array.jl +++ b/base/array.jl @@ -564,7 +564,7 @@ function deleteat!(a::Vector, inds) q = p+1 while !done(inds, s) (i,s) = next(inds, s) - if !(q <= i <= n) + if !(q <= i <= n) i < q && error("indices must be unique and sorted") throw(BoundsError()) end @@ -761,7 +761,7 @@ end # familiar aliases for broadcasting operations of array ± scalar (#7226): (+)(A::AbstractArray{Bool},x::Bool) = A .+ x -(+)(x::Bool,A::AbstractArray{Bool}) = x .+ A +(+)(x::Bool,A::AbstractArray{Bool}) = x .+ A (-)(A::AbstractArray{Bool},x::Bool) = A .- x (-)(x::Bool,A::AbstractArray{Bool}) = x .- A (+)(A::AbstractArray,x::Number) = A .+ x @@ -795,7 +795,7 @@ for f in (:+, :-) for i=1:length(A) @inbounds F[i] = ($f)(A[i], B[i]) end - return F + return F end end end diff --git a/base/client.jl b/base/client.jl index 6f77d62743c33..53efba51dd256 100644 --- a/base/client.jl +++ b/base/client.jl @@ -189,7 +189,7 @@ function init_bind_addr(args::Vector{UTF8String}) bind_addr = getipaddr() catch # All networking is unavailable, initialize bind_addr to the loopback address - # Will cause an exception to be raised only when used. + # Will cause an exception to be raised only when used. bind_addr = ip"127.0.0.1" end end @@ -309,7 +309,7 @@ const LOAD_PATH = ByteString[] function init_load_path() vers = "v$(VERSION.major).$(VERSION.minor)" if haskey(ENV,"JULIA_LOAD_PATH") - prepend!(LOAD_PATH, split(ENV["JULIA_LOAD_PATH"], @windows? ';' : ':')) + prepend!(LOAD_PATH, split(ENV["JULIA_LOAD_PATH"], @windows? ';' : ':')) end push!(LOAD_PATH,abspath(JULIA_HOME,"..","local","share","julia","site",vers)) push!(LOAD_PATH,abspath(JULIA_HOME,"..","share","julia","site",vers)) diff --git a/base/complex.jl b/base/complex.jl index 5410737299c6c..544211050eb9b 100644 --- a/base/complex.jl +++ b/base/complex.jl @@ -154,7 +154,7 @@ inv{T<:Union(Float16,Float32)}(z::Complex{T}) = # the first step is to scale variables if appropriate ,then do calculations # in a way that avoids over/underflow (subfuncs 1 and 2), then undo the scaling. # scaling variable s and other techniques -# based on arxiv.1210.4539 +# based on arxiv.1210.4539 # a + i*b # p + i*q = --------- # c + i*d @@ -368,10 +368,10 @@ function expm1(z::Complex) Complex(oftype(zr,NaN), oftype(zi,NaN)) end else - erm1 = expm1(zr) + erm1 = expm1(zr) if zi == 0 Complex(erm1, zi) - else + else er = erm1+one(erm1) wr = isfinite(er) ? erm1 - 2.0*er*(sin(0.5*zi))^2 : er*cos(zi) Complex(wr, er*sin(zi)) diff --git a/base/dSFMT.jl b/base/dSFMT.jl index 62e99c62d6d5f..7af8690de40f8 100644 --- a/base/dSFMT.jl +++ b/base/dSFMT.jl @@ -19,7 +19,7 @@ end function dsfmt_get_min_array_size() min_array_size = ccall((:dsfmt_get_min_array_size,:libdSFMT), - Int32, + Int32, ()) end @@ -27,15 +27,15 @@ const dsfmt_min_array_size = dsfmt_get_min_array_size() function dsfmt_init_gen_rand(s::DSFMT_state, seed::UInt32) ccall((:dsfmt_init_gen_rand,:libdSFMT), - Void, - (Ptr{Void}, UInt32,), + Void, + (Ptr{Void}, UInt32,), s.val, seed) end function dsfmt_init_by_array(s::DSFMT_state, seed::Vector{UInt32}) ccall((:dsfmt_init_by_array,:libdSFMT), - Void, - (Ptr{Void}, Ptr{UInt32}, Int32), + Void, + (Ptr{Void}, Ptr{UInt32}, Int32), s.val, seed, length(seed)) end diff --git a/base/darray.jl b/base/darray.jl index 70428e627c427..22e8114cd72b7 100644 --- a/base/darray.jl +++ b/base/darray.jl @@ -212,9 +212,9 @@ function reshape{T,S<:Array}(A::DArray{T,1,S}, d::Dims) for i=1:div(length(B),nr) i2 = ind2sub(sztail, i) globalidx = [ I[j][i2[j-1]] for j=2:nd ] - + a = sub2ind(d, d1offs, globalidx...) - + B[:,i] = A[a:(a+nr-1)] end B @@ -304,8 +304,8 @@ reduce(f::Function, d::DArray) = mapreduce(fetch, f, Any[ @spawnat p reduce(f, localpart(d)) for p in procs(d) ]) - -function map!(f::Callable, d::DArray) + +function map!(f::Callable, d::DArray) @sync begin for p in procs(d) @spawnat p map!(f, localpart(d)) diff --git a/base/datafmt.jl b/base/datafmt.jl index cd932d90912d4..161cb6f231324 100644 --- a/base/datafmt.jl +++ b/base/datafmt.jl @@ -67,7 +67,7 @@ function ascii_if_possible(sbuff::AbstractString) isascii(sbuff) ? convert(ASCIIString,sbuff) : sbuff end -# +# # Handlers act on events generated by the parser. # Parser calls store_cell on the handler to pass events. # @@ -148,7 +148,7 @@ function DLMStore{T,S<:AbstractString}(::Type{T}, dims::NTuple{2,Integer}, has_h DLMStore{T,S}(fill(SubString(sbuff,1,0), 1, ncols), Array(T, nrows-hdr_offset, ncols), nrows, ncols, 0, 0, hdr_offset, sbuff, auto, eol, Array(Float64,1)) end -function store_cell{T,S<:AbstractString}(dlmstore::DLMStore{T,S}, row::Int, col::Int, quoted::Bool, startpos::Int, endpos::Int) +function store_cell{T,S<:AbstractString}(dlmstore::DLMStore{T,S}, row::Int, col::Int, quoted::Bool, startpos::Int, endpos::Int) drow = row - dlmstore.hdr_offset ncols = dlmstore.ncols @@ -190,14 +190,14 @@ function store_cell{T,S<:AbstractString}(dlmstore::DLMStore{T,S}, row::Int, col: if fail ((T <: Number) && dlmstore.auto) ? throw(TypeError(:store_cell, "", Any, T)) : error("file entry \"$(sval)\" cannot be converted to $T") end - + dlmstore.lastrow = drow dlmstore.lastcol = col else # fill header colval((quoted && ('"' in sval)) ? replace(sval, r"\"\"", "\"") : sval, dlmstore.hdr, 1, col, tmp64) - end - + end + nothing end @@ -321,9 +321,9 @@ colval{T<:Char, S<:AbstractString}(sval::S, cells::Array{T,2}, row::Int, col::In colval{S<:AbstractString}(sval::S, cells::Array, row::Int, col::Int, tmp64::Array{Float64,1}) = true dlm_parse(s::ASCIIString, eol::Char, dlm::Char, qchar::Char, cchar::Char, ign_adj_dlm::Bool, allow_quote::Bool, allow_comments::Bool, skipstart::Int, skipblanks::Bool, dh::DLMHandler) = begin - dlm_parse(s.data, uint8(uint32(eol)), uint8(uint32(dlm)), uint8(uint32(qchar)), uint8(uint32(cchar)), + dlm_parse(s.data, uint8(uint32(eol)), uint8(uint32(dlm)), uint8(uint32(qchar)), uint8(uint32(cchar)), ign_adj_dlm, allow_quote, allow_comments, skipstart, skipblanks, dh) -end +end function dlm_parse{T,D}(dbuff::T, eol::D, dlm::D, qchar::D, cchar::D, ign_adj_dlm::Bool, allow_quote::Bool, allow_comments::Bool, skipstart::Int, skipblanks::Bool, dh::DLMHandler) all_ascii = (D <: UInt8) || (isascii(eol) && isascii(dlm) && (!allow_quote || isascii(qchar)) && (!allow_comments || isascii(cchar))) @@ -388,7 +388,7 @@ function dlm_parse{T,D}(dbuff::T, eol::D, dlm::D, qchar::D, cchar::D, ign_adj_dl state = (allow_quote && !was_cr) ? 1 : 2 expct_col = false elseif is_dlm - if !ign_adj_dlm + if !ign_adj_dlm expct_col = true col += 1 store_cell(dh, nrows+1, col, false, col_start_idx, idx-2) @@ -397,7 +397,7 @@ function dlm_parse{T,D}(dbuff::T, eol::D, dlm::D, qchar::D, cchar::D, ign_adj_dl elseif is_eol if (col > 0) || !skipblanks nrows += 1 - if expct_col + if expct_col col += 1 store_cell(dh, nrows, col, false, col_start_idx, idx - (was_cr ? 3 : 2)) end @@ -478,7 +478,7 @@ function dlm_parse{T,D}(dbuff::T, eol::D, dlm::D, qchar::D, cchar::D, ign_adj_dl end end !isempty(error_str) && error(error_str) - + return (nrows, ncols) end diff --git a/base/dates/accessors.jl b/base/dates/accessors.jl index 3f9916487d0bc..cb95f47fc30d4 100644 --- a/base/dates/accessors.jl +++ b/base/dates/accessors.jl @@ -7,12 +7,12 @@ function yearmonthday(days) end function year(days) z = days + 306; h = 100z - 25; a = fld(h,3652425); b = a - fld(a,4); - y = fld(100b+h,36525); c = b + z - 365y - fld(y,4); m = div(5c+456,153); + y = fld(100b+h,36525); c = b + z - 365y - fld(y,4); m = div(5c+456,153); return m > 12 ? y+1 : y end function yearmonth(days) z = days + 306; h = 100z - 25; a = fld(h,3652425); b = a - fld(a,4); - y = fld(100b+h,36525); c = b + z - 365y - fld(y,4); m = div(5c+456,153); + y = fld(100b+h,36525); c = b + z - 365y - fld(y,4); m = div(5c+456,153); return m > 12 ? (y+1,m-12) : (y,m) end function month(days) @@ -27,7 +27,7 @@ function monthday(days) end function day(days) z = days + 306; h = 100z - 25; a = fld(h,3652425); b = a - fld(a,4); - y = fld(100b+h,36525); c = b + z - 365y - fld(y,4); m = div(5c+456,153); + y = fld(100b+h,36525); c = b + z - 365y - fld(y,4); m = div(5c+456,153); return c - div(153m-457,5) end # https://en.wikipedia.org/wiki/Talk:ISO_week_date#Algorithms diff --git a/base/dates/adjusters.jl b/base/dates/adjusters.jl index 304c6b7bde945..7e88c3846679d 100644 --- a/base/dates/adjusters.jl +++ b/base/dates/adjusters.jl @@ -22,7 +22,7 @@ lastdayofweek(dt::DateTime) = DateTime(lastdayofweek(Date(dt))) firstdayofmonth(dt::Date) = Date(UTD(value(dt)-day(dt)+1)) firstdayofmonth(dt::DateTime) = DateTime(firstdayofmonth(Date(dt))) -function lastdayofmonth(dt::Date) +function lastdayofmonth(dt::Date) y,m,d = yearmonthday(dt) return Date(UTD(value(dt)+daysinmonth(y,m)-d)) end diff --git a/base/dates/arithmetic.jl b/base/dates/arithmetic.jl index aff3131f098fa..51d7515ae0129 100644 --- a/base/dates/arithmetic.jl +++ b/base/dates/arithmetic.jl @@ -37,25 +37,25 @@ monthwrap(m1,m2) = (v = mod1(m1+m2,12); return v < 0 ? 12 + v : v) # the resulting year with wraparound behavior (i.e. 2000-12 + 1 == 2001) yearwrap(y,m1,m2) = y + fld(m1 + m2 - 1,12) -function (+)(dt::DateTime,z::Month) +function (+)(dt::DateTime,z::Month) y,m,d = yearmonthday(dt) ny = yearwrap(y,m,value(z)) mm = monthwrap(m,value(z)); ld = daysinmonth(ny,mm) return DateTime(ny,mm,d <= ld ? d : ld,hour(dt),minute(dt),second(dt),millisecond(dt)) end -function (+)(dt::Date,z::Month) +function (+)(dt::Date,z::Month) y,m,d = yearmonthday(dt) ny = yearwrap(y,m,value(z)) mm = monthwrap(m,value(z)); ld = daysinmonth(ny,mm) return Date(ny,mm,d <= ld ? d : ld) end -function (-)(dt::DateTime,z::Month) +function (-)(dt::DateTime,z::Month) y,m,d = yearmonthday(dt) ny = yearwrap(y,m,-value(z)) mm = monthwrap(m,-value(z)); ld = daysinmonth(ny,mm) return DateTime(ny,mm,d <= ld ? d : ld,hour(dt),minute(dt),second(dt),millisecond(dt)) end -function (-)(dt::Date,z::Month) +function (-)(dt::Date,z::Month) y,m,d = yearmonthday(dt) ny = yearwrap(y,m,-value(z)) mm = monthwrap(m,-value(z)); ld = daysinmonth(ny,mm) diff --git a/base/dates/io.jl b/base/dates/io.jl index fc432c89bb561..509b2ce230ac8 100644 --- a/base/dates/io.jl +++ b/base/dates/io.jl @@ -72,10 +72,10 @@ function DateFormat(f::AbstractString,locale::AbstractString="english") slot = tran == "" || tran == r"$" ? FixedWidthSlot : DelimitedSlot width = length(k) typ = 'E' in k ? DayOfWeekSlot : 'e' in k ? DayOfWeekSlot : - 'y' in k ? Year : 'm' in k ? Month : + 'y' in k ? Year : 'm' in k ? Month : 'u' in k ? Month : 'U' in k ? Month : - 'd' in k ? Day : 'H' in k ? Hour : - 'M' in k ? Minute : 'S' in k ? Second : Millisecond + 'd' in k ? Day : 'H' in k ? Hour : + 'M' in k ? Minute : 'S' in k ? Second : Millisecond option = 'E' in k ? 2 : 'e' in k ? 1 : 'U' in k ? 2 : 'u' in k ? 1 : 0 push!(slots,slot(i,typ,width,option,locale)) diff --git a/base/dates/query.jl b/base/dates/query.jl index c2d2afe1826ec..459a8fa194301 100644 --- a/base/dates/query.jl +++ b/base/dates/query.jl @@ -38,7 +38,7 @@ issaturday(dt::TimeType) = dayofweek(dt) == Sat issunday(dt::TimeType) = dayofweek(dt) == Sun # i.e. 1st Monday? 2nd Monday? 3rd Wednesday? 5th Sunday? -dayofweekofmonth(dt::TimeType) = (d = day(dt); return d < 8 ? 1 : +dayofweekofmonth(dt::TimeType) = (d = day(dt); return d < 8 ? 1 : d < 15 ? 2 : d < 22 ? 3 : d < 29 ? 4 : 5) # Total number of a day of week in the month diff --git a/base/dates/types.jl b/base/dates/types.jl index b1e5e437f2dd0..2767716612c98 100644 --- a/base/dates/types.jl +++ b/base/dates/types.jl @@ -42,7 +42,7 @@ end UTM(x) = UTInstant(Millisecond(x)) UTD(x) = UTInstant(Day(x)) -# Calendar types provide rules for interpretating instant +# Calendar types provide rules for interpretating instant # timelines in human-readable form. abstract Calendar <: AbstractTime @@ -60,7 +60,7 @@ abstract TimeType <: AbstractTime # DateTime is a millisecond precision UTInstant interpreted by ISOCalendar immutable DateTime <: TimeType instant::UTInstant{Millisecond} -end +end # DateTime is a day precision UTInstant interpreted by ISOCalendar immutable Date <: TimeType diff --git a/base/dsp.jl b/base/dsp.jl index 0062bbb64b48f..e8e611bff323e 100644 --- a/base/dsp.jl +++ b/base/dsp.jl @@ -185,7 +185,7 @@ fftwcopy{T<:fftwNumber}(X::StridedArray{T}) = copy(X) fftwcopy{T<:Real}(X::StridedArray{T}) = float(X) fftwcopy{T<:Complex}(X::StridedArray{T}) = complex128(X) -for (f, fr2r, Y, Tx) in ((:dct, :r2r, :Y, :Number), +for (f, fr2r, Y, Tx) in ((:dct, :r2r, :Y, :Number), (:dct!, :r2r!, :X, :fftwNumber)) plan_f = symbol(string("plan_",f)) plan_fr2r = symbol(string("plan_",fr2r)) @@ -259,7 +259,7 @@ for (f, fr2r, Y, Tx) in ((:dct, :r2r, :Y, :Number), for (g,plan_g) in ((f,plan_f), (fi, plan_fi)) @eval begin $g{T<:$Tx}(X::StridedArray{T}) = $g(X, 1:ndims(X)) - + $plan_g(X, region, flags::Unsigned) = $plan_g(X, region, flags, NO_TIMELIMIT) $plan_g(X, region) = diff --git a/base/fftw.jl b/base/fftw.jl index 1351fa20dd136..3022566dc40c6 100644 --- a/base/fftw.jl +++ b/base/fftw.jl @@ -131,35 +131,35 @@ execute(precision::fftwTypeSingle, plan) = ccall((:fftwf_execute,libfftwf), Void, (Ptr{Void},), plan) execute(plan, X::StridedArray{Complex128}, Y::StridedArray{Complex128}) = - ccall((:fftw_execute_dft,libfftw), Void, + ccall((:fftw_execute_dft,libfftw), Void, (Ptr{Void},Ptr{Complex128},Ptr{Complex128}), plan, X, Y) execute(plan, X::StridedArray{Complex64}, Y::StridedArray{Complex64}) = - ccall((:fftwf_execute_dft,libfftwf), Void, + ccall((:fftwf_execute_dft,libfftwf), Void, (Ptr{Void},Ptr{Complex64},Ptr{Complex64}), plan, X, Y) execute(plan, X::StridedArray{Float64}, Y::StridedArray{Complex128}) = - ccall((:fftw_execute_dft_r2c,libfftw), Void, + ccall((:fftw_execute_dft_r2c,libfftw), Void, (Ptr{Void},Ptr{Float64},Ptr{Complex128}), plan, X, Y) execute(plan, X::StridedArray{Float32}, Y::StridedArray{Complex64}) = - ccall((:fftwf_execute_dft_r2c,libfftwf), Void, + ccall((:fftwf_execute_dft_r2c,libfftwf), Void, (Ptr{Void},Ptr{Float32},Ptr{Complex64}), plan, X, Y) execute(plan, X::StridedArray{Complex128}, Y::StridedArray{Float64}) = - ccall((:fftw_execute_dft_c2r,libfftw), Void, + ccall((:fftw_execute_dft_c2r,libfftw), Void, (Ptr{Void},Ptr{Complex128},Ptr{Float64}), plan, X, Y) execute(plan, X::StridedArray{Complex64}, Y::StridedArray{Float32}) = - ccall((:fftwf_execute_dft_c2r,libfftwf), Void, + ccall((:fftwf_execute_dft_c2r,libfftwf), Void, (Ptr{Void},Ptr{Complex64},Ptr{Float32}), plan, X, Y) execute_r2r{T<:fftwDouble}(plan, X::StridedArray{T}, Y::StridedArray{T}) = - ccall((:fftw_execute_r2r,libfftw), Void, + ccall((:fftw_execute_r2r,libfftw), Void, (Ptr{Void},Ptr{T},Ptr{T}), plan, X, Y) execute_r2r{T<:fftwSingle}(plan, X::StridedArray{T}, Y::StridedArray{T}) = - ccall((:fftwf_execute_r2r,libfftwf), Void, + ccall((:fftwf_execute_r2r,libfftwf), Void, (Ptr{Void},Ptr{T},Ptr{T}), plan, X, Y) execute{T<:fftwReal}(plan, X::StridedArray{T}, Y::StridedArray{T}) = @@ -189,7 +189,7 @@ set_timelimit(precision::fftwTypeSingle,seconds) = # to exploit SIMD operations. Julia arrays are, by default, aligned # to 16-byte boundaries (address mod 16 == 0), but this may not be # true for data imported from external C code, or for SubArrays. -# Use the undocumented routine fftw_alignment_of to determine the +# Use the undocumented routine fftw_alignment_of to determine the # alignment of a given pointer modulo whatever FFTW needs. if Base.libfftw_name == "libmkl_rt" @@ -251,7 +251,7 @@ end # re-use the table of trigonometric constants from the first plan. # Compute dims and howmany for FFTW guru planner -function dims_howmany(X::StridedArray, Y::StridedArray, +function dims_howmany(X::StridedArray, Y::StridedArray, sz::Array{Int,1}, region) reg = [region...] if length(unique(reg)) < length(reg) @@ -408,10 +408,10 @@ complexfloat{T<:Complex}(X::StridedArray{T}) = complex128(X) # # fft(x [, region]) - FFT of x, creating and destroying a plan, # optionally acting only on a subset of the dimensions -# p = plan_fft(x, [, region [, flags [, timelimit]]]) +# p = plan_fft(x, [, region [, flags [, timelimit]]]) # -- returns a function p(x) that performs efficient FFTs -# of a given size (on given dimensions) with variants -# to specify the FFTW planner flags (default is ESTIMATE) and +# of a given size (on given dimensions) with variants +# to specify the FFTW planner flags (default is ESTIMATE) and # timelimit (default: NO_TIMELIMIT). # # along with in-place variants fft! and plan_fft! if feasible. @@ -436,14 +436,14 @@ for (f,direction) in ((:fft,:FORWARD), (:bfft,:BACKWARD)) # do not destroy_plan ... see above note on gc return X end - + function $f{T<:Number}(X::StridedArray{T}, region) Y = complexfloat(X) # in-place transform return $f!(Y, region) end function $plan_f{T<:fftwComplex}(X::StridedArray{T}, - region, + region, flags::Unsigned, tlim::Real) Y = similar(X, T) @@ -455,8 +455,8 @@ for (f,direction) in ((:fft,:FORWARD), (:bfft,:BACKWARD)) return W end end - - function $plan_f{T<:Number}(X::StridedArray{T}, region, + + function $plan_f{T<:Number}(X::StridedArray{T}, region, flags::Unsigned, tlim::Real) Y = complexfloat(X) # in-place transform p = Plan(Y, Y, region, $direction, flags, tlim) @@ -467,7 +467,7 @@ for (f,direction) in ((:fft,:FORWARD), (:bfft,:BACKWARD)) return W end end - + function $plan_f!{T<:fftwComplex}(X::StridedArray{T}, region, flags::Unsigned, @@ -509,14 +509,14 @@ for (f,fb) in ((:ifft,:bfft), (:ifft!,:bfft!)) $f(X, region) = scale!($fb(X, region), normalization(X, region)) $f(X) = scale!($fb(X), normalization(X)) - function $pf(X, region, flags, tlim) + function $pf(X, region, flags, tlim) nrm = normalization(X, region) p = $pfb(X, region, flags, tlim) return Z -> scale!(p(Z), nrm) end $pf(X, region, flags) = $pf(X, region, flags, NO_TIMELIMIT) $pf(X, region) = $pf(X, region, ESTIMATE, NO_TIMELIMIT) - function $pf(X) + function $pf(X) nrm = normalization(X) p = $pfb(X) return Z -> scale!(p(Z), nrm) @@ -575,7 +575,7 @@ for (Tr,Tc) in ((:Float32,:Complex64),(:Float64,:Complex128)) end # variant that destroys input X - function brfftd(X::StridedArray{$Tc}, d::Integer, region) + function brfftd(X::StridedArray{$Tc}, d::Integer, region) d1 = region[1] osize = [size(X)...] @assert osize[d1] == d>>1 + 1 @@ -587,7 +587,7 @@ for (Tr,Tc) in ((:Float32,:Complex64),(:Float64,:Complex128)) return Y end - function brfft(X::StridedArray{$Tc}, d::Integer, region) + function brfft(X::StridedArray{$Tc}, d::Integer, region) if length(region) == 1 return brfft(X, d, convert(Int, region[1])) end diff --git a/base/file.jl b/base/file.jl index 8f3971f3577a0..d2121477085d5 100644 --- a/base/file.jl +++ b/base/file.jl @@ -7,7 +7,7 @@ function pwd() bytestring(b[1:len[1]-1]) end -function cd(dir::AbstractString) +function cd(dir::AbstractString) uv_error("chdir $dir", ccall(:uv_chdir, Cint, (Ptr{UInt8},), dir)) end cd() = cd(homedir()) @@ -104,7 +104,7 @@ end return (b, fdio(p, true)) end -@windows_only begin +@windows_only begin function tempdir() temppath = Array(UInt16,32767) lentemppath = ccall(:GetTempPathW,stdcall,UInt32,(UInt32,Ptr{UInt16}),length(temppath),temppath) diff --git a/base/float.jl b/base/float.jl index ffcff8a459a42..81739f0ca2a4e 100644 --- a/base/float.jl +++ b/base/float.jl @@ -17,7 +17,7 @@ end for t1 in (Float32,Float64) for st in (Int8,Int16,Int32,Int64) - @eval begin + @eval begin convert(::Type{$t1},x::($st)) = box($t1,sitofp($t1,unbox($st,x))) promote_rule(::Type{$t1}, ::Type{$st} ) = $t1 end diff --git a/base/fs.jl b/base/fs.jl index f389ee226d530..c44dd47272d3a 100644 --- a/base/fs.jl +++ b/base/fs.jl @@ -159,7 +159,7 @@ end end uv_error("symlink",err) end -@windowsxp_only symlink(p::AbstractString, np::AbstractString) = +@windowsxp_only symlink(p::AbstractString, np::AbstractString) = error("WindowsXP does not support soft symlinks") function chmod(p::AbstractString, mode::Integer) diff --git a/base/gmp.jl b/base/gmp.jl index e648ca3ad37cb..cb0d50d2c64f6 100644 --- a/base/gmp.jl +++ b/base/gmp.jl @@ -459,7 +459,7 @@ function ndigits0z(x::BigInt, b::Integer=10) q,r = divrem(n,lb) iq = int(q) maxerr = q*eps(lb) # maximum error in remainder - if r-1.0 < maxerr + if r-1.0 < maxerr abs(x) >= big(b)^iq ? iq+1 : iq elseif lb-r < maxerr abs(x) >= big(b)^(iq+1) ? iq+2 : iq+1 diff --git a/base/graphics.jl b/base/graphics.jl index 0722fe750aed8..32924acf45241 100644 --- a/base/graphics.jl +++ b/base/graphics.jl @@ -9,9 +9,9 @@ export isinside, xmin, xmax, ymin, ymax, center, xrange, yrange, aspect_ratio, with_aspect_ratio, diagonal, shift, deform, # TODO: more - + # TODO: 3D geometry - + # Part 2. 2D Drawing # device and context GraphicsDevice, GraphicsContext, creategc, getgc, @@ -19,32 +19,32 @@ export # but in device coordinates for GraphicsDevice, GraphicsContext, and # other concrete things like windows and widgets. width, height, - + # drawing attribute manipulation save, restore, set_line_width, set_dash, set_source_rgb, set_source_rgba, set_source, - + # coordinate systems reset_transform, set_coords, rotate, scale, translate, user_to_device!, device_to_user!, user_to_device_distance!, device_to_user_distance!, user_to_device, device_to_user, - + # clipping clip, clip_preserve, reset_clip, - + # path primitives move_to, line_to, rel_line_to, rel_move_to, new_path, new_sub_path, close_path, arc, - + # fill and stroke fill, fill_preserve, paint, stroke, stroke_preserve, stroke_transformed, stroke_transformed_preserve, - + # derived path operations rectangle, circle, polygon - + # TODO: text drawing API - + # TODO: rendering pipeline API diff --git a/base/grisu/LICENSE b/base/grisu/LICENSE index 6a8468602a15f..bd693139e68d3 100644 --- a/base/grisu/LICENSE +++ b/base/grisu/LICENSE @@ -23,4 +23,4 @@ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/base/grisu/bignum.jl b/base/grisu/bignum.jl index eb8175aee5f76..a5f30df2e5881 100644 --- a/base/grisu/bignum.jl +++ b/base/grisu/bignum.jl @@ -1,5 +1,5 @@ function normalizedexponent(significand, exponent::Int32) - significand::UInt64 + significand::UInt64 while (significand & HiddenBit(Float64)) == 0 significand <<= 1 exponent -= 1 @@ -49,7 +49,7 @@ function generateshortestdigits(num,den,minus,plus,is_even,buffer) len += 1 in_delta_room_minus = is_even ? num <= minus : num < minus in_delta_room_plus = is_even ? num + plus >= den : num + plus > den - + if !in_delta_room_minus && !in_delta_room_plus num *= 10 minus *= 10 diff --git a/base/grisu/fastprecision.jl b/base/grisu/fastprecision.jl index 03db265d29b48..d14caad050c57 100644 --- a/base/grisu/fastprecision.jl +++ b/base/grisu/fastprecision.jl @@ -50,7 +50,7 @@ function digitgen(w,buffer,requested_digits=1000) requested_digits -= 1 fractionals &= one.s - 1 kappa -= 1 - end + end requested_digits != 0 && return false, kappa, len r, kappa = roundweed(buffer,len,fractionals,one.s, unit,kappa) diff --git a/base/grisu/fastshortest.jl b/base/grisu/fastshortest.jl index 4059d74ec8a78..9a3360313c505 100644 --- a/base/grisu/fastshortest.jl +++ b/base/grisu/fastshortest.jl @@ -21,7 +21,7 @@ function roundweed(buffer,len,rest,tk,unit,kappa,too_high::UInt64,unsafe_interva end const SmallPowersOfTen = [ - 0, 1, 10, 100, 1000, 10000, 100000, + 0, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000] function bigpowten(n,n_bits) @@ -69,7 +69,7 @@ function digitgen(low,w,high,buffer) unit,kappa,(too_high - w).s*unit,unsafe_interval.s) return r, kappa, len end - end + end end function fastshortest(v,buffer=Array(UInt8,17)) diff --git a/base/grisu/float.jl b/base/grisu/float.jl index f84a7c641ca52..e23520dcdeb02 100644 --- a/base/grisu/float.jl +++ b/base/grisu/float.jl @@ -34,7 +34,7 @@ function normalize(v::Float64) end s <<= uint64(FloatSignificandSize - SignificandSize(Float64)) e -= int32( FloatSignificandSize - SignificandSize(Float64)) - return Float(s, e) + return Float(s, e) end # Float128 diff --git a/base/inference.jl b/base/inference.jl index 6efc82af570ec..08123a206c062 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -1929,7 +1929,7 @@ function without_linenums(a::Array{Any,1}) end # known affect-free calls (also effect-free) -const _pure_builtins = Any[tuple, tupleref, tuplelen, fieldtype, apply_type, is, isa, typeof, typeassert] +const _pure_builtins = Any[tuple, tupleref, tuplelen, fieldtype, apply_type, is, isa, typeof, typeassert] # known effect-free calls (might not be affect-free) const _pure_builtins_volatile = Any[getfield, arrayref] diff --git a/base/intset.jl b/base/intset.jl index 19f1eaf6660a8..e2416fb6f43a7 100644 --- a/base/intset.jl +++ b/base/intset.jl @@ -223,7 +223,7 @@ function intersect!(s::IntSet, s2::IntSet) for n = 1:lim s.bits[n] &= s2.bits[n] end - if !s2.fill1s + if !s2.fill1s for n=lim+1:length(s.bits) s.bits[n] = uint32(0) end diff --git a/base/iobuffer.jl b/base/iobuffer.jl index 57b274dec41ad..e86f2c214553b 100644 --- a/base/iobuffer.jl +++ b/base/iobuffer.jl @@ -12,11 +12,11 @@ type IOBuffer <: IO ptr::Int # read (and maybe write) pointer mark::Int - IOBuffer(data::Vector{UInt8},readable::Bool,writable::Bool,seekable::Bool,append::Bool,maxsize::Int) = + IOBuffer(data::Vector{UInt8},readable::Bool,writable::Bool,seekable::Bool,append::Bool,maxsize::Int) = new(data,readable,writable,seekable,append,length(data),maxsize,1,-1) end -function copy(b::IOBuffer) +function copy(b::IOBuffer) ret = IOBuffer(b.writable?copy(b.data):b.data, b.readable,b.writable,b.seekable,b.append,b.maxsize) ret.size = b.size @@ -94,7 +94,7 @@ function peek(from::IOBuffer) throw(EOFError()) end return from.data[from.ptr] -end +end read{T}(from::IOBuffer, ::Type{Ptr{T}}) = convert(Ptr{T}, read(from, UInt)) @@ -149,7 +149,7 @@ function compact(io::IOBuffer) ptr = io.ptr bytes_to_move = nb_available(io) end - ccall(:memmove, Ptr{Void}, (Ptr{Void},Ptr{Void},UInt), + ccall(:memmove, Ptr{Void}, (Ptr{Void},Ptr{Void},UInt), io.data, pointer(io.data,ptr), bytes_to_move) io.size -= ptr - 1 io.ptr -= ptr - 1 @@ -227,7 +227,7 @@ function takebuf_array(io::IOBuffer) end takebuf_string(io::IOBuffer) = bytestring(takebuf_array(io)) -function write(to::IOBuffer, from::IOBuffer) +function write(to::IOBuffer, from::IOBuffer) write(to, pointer(from.data,from.ptr), nb_available(from)) from.ptr += nb_available(from) end diff --git a/base/iterator.jl b/base/iterator.jl index 2cd3bb77ab753..60af28fdb97f5 100644 --- a/base/iterator.jl +++ b/base/iterator.jl @@ -53,7 +53,7 @@ zip(a, b) = Zip2(a, b) length(z::Zip2) = min(length(z.a), length(z.b)) start(z::Zip2) = (start(z.a), start(z.b)) -function next(z::Zip2, st) +function next(z::Zip2, st) n1 = next(z.a,st[1]) n2 = next(z.b,st[2]) return ((n1[1], n2[1]), (n1[2], n2[2])) diff --git a/base/latex_symbols.jl b/base/latex_symbols.jl index 5b3693f120882..288dc21fd7847 100644 --- a/base/latex_symbols.jl +++ b/base/latex_symbols.jl @@ -54,7 +54,7 @@ open("unicode-math-table.tex") do f c = char(parseint(x[2], 16)) if (Base.is_id_char(c) || Base.isoperator(symbol(c))) && string(c) ∉ latex_strings && !isascii(c) - println(" \"", escape_string(x[3]), "\" => \"", + println(" \"", escape_string(x[3]), "\" => \"", escape_string("$c"), "\", # ", x[5]) end end diff --git a/base/linalg.jl b/base/linalg.jl index 3caf2d1a6074e..4b34c00a804b9 100644 --- a/base/linalg.jl +++ b/base/linalg.jl @@ -3,7 +3,7 @@ module LinAlg importall Base import Base: USE_BLAS64, size, copy, copy_transpose!, power_by_squaring, print_matrix, transpose! -export +export # Modules LAPACK, BLAS, @@ -161,9 +161,9 @@ end #Check that stride of matrix/vector is 1 function chkstride1(A::StridedVecOrMat...) - for a in A + for a in A stride(a,1)== 1 || error("matrix does not have contiguous columns") - end + end end #Check that matrix is square @@ -175,7 +175,7 @@ end function chksquare(A...) sizes = Int[] - for a in A + for a in A size(a,1)==size(a,2) || throw(DimensionMismatch("matrix is not square: dimensions are $(size(a))")) push!(sizes, size(a,1)) end @@ -185,7 +185,7 @@ end #Check that upper/lower (for special matrices) is correctly specified macro chkuplo() :((uplo=='U' || uplo=='L') || throw(ArgumentError("""invalid uplo = $uplo - + Valid choices are 'U' (upper) or 'L' (lower)."""))) end diff --git a/base/linalg/arnoldi.jl b/base/linalg/arnoldi.jl index 41fd670423283..c3728187045e2 100644 --- a/base/linalg/arnoldi.jl +++ b/base/linalg/arnoldi.jl @@ -30,7 +30,7 @@ function eigs(A, B; isgeneral && !isposdef(B) && throw(PosDefException(0)) bmat = isgeneral ? "G" : "I" isshift = sigma !== nothing - + if isa(which,AbstractString) warn("Use symbols instead of strings for specifying which eigenvalues to compute") which=symbol(which) @@ -44,7 +44,7 @@ function eigs(A, B; sigma=zero(T) which=:LM end - + if sigma != nothing && !iscmplx && isa(sigma,Complex) error("complex shifts for real problems are not yet supported") end @@ -54,7 +54,7 @@ function eigs(A, B; length(v0)==n || throw(DimensionMismatch("")) eltype(v0)==T || error("Starting vector must have eltype $T") end - + whichstr = "LM" if which == :BE whichstr = "BE" @@ -98,9 +98,9 @@ function eigs(A, B; end # Compute the Ritz values and Ritz vectors - (resid, v, ldv, iparam, ipntr, workd, workl, lworkl, rwork, TOL) = + (resid, v, ldv, iparam, ipntr, workd, workl, lworkl, rwork, TOL) = ARPACK.aupd_wrapper(T, matvecA, matvecB, solveSI, n, sym, iscmplx, bmat, nev, ncv, whichstr, tol, maxiter, mode, v0) - + # Postprocessing to get eigenvalues and eigenvectors return ARPACK.eupd_wrapper(T, n, sym, iscmplx, bmat, nev, whichstr, ritzvec, TOL, resid, ncv, v, ldv, sigma, iparam, ipntr, workd, workl, lworkl, rwork) diff --git a/base/linalg/arpack.jl b/base/linalg/arpack.jl index 49c05a6835a35..f3111866601cd 100644 --- a/base/linalg/arpack.jl +++ b/base/linalg/arpack.jl @@ -1,12 +1,12 @@ -module ARPACK +module ARPACK import ..LinAlg: BlasInt, blas_int, ARPACKException -## aupd and eupd wrappers +## aupd and eupd wrappers function aupd_wrapper(T, matvecA::Function, matvecB::Function, solveSI::Function, n::Integer, sym::Bool, cmplx::Bool, bmat::ASCIIString, - nev::Integer, ncv::Integer, which::ASCIIString, + nev::Integer, ncv::Integer, which::ASCIIString, tol::Real, maxiter::Integer, mode::Integer, v0::Vector) lworkl = cmplx ? ncv * (3*ncv + 5) : (sym ? ncv * (ncv + 8) : ncv * (3*ncv + 6) ) @@ -39,7 +39,7 @@ function aupd_wrapper(T, matvecA::Function, matvecB::Function, solveSI::Function while true if cmplx naupd(ido, bmat, n, which, nev, TOL, resid, ncv, v, n, - iparam, ipntr, workd, workl, lworkl, rwork, info) + iparam, ipntr, workd, workl, lworkl, rwork, info) elseif sym saupd(ido, bmat, n, which, nev, TOL, resid, ncv, v, n, iparam, ipntr, workd, workl, lworkl, info) @@ -47,7 +47,7 @@ function aupd_wrapper(T, matvecA::Function, matvecB::Function, solveSI::Function naupd(ido, bmat, n, which, nev, TOL, resid, ncv, v, n, iparam, ipntr, workd, workl, lworkl, info) end - + load_idx = ipntr[1]+zernm1 store_idx = ipntr[2]+zernm1 x = workd[load_idx] @@ -97,7 +97,7 @@ function aupd_wrapper(T, matvecA::Function, matvecB::Function, solveSI::Function error("ARPACK mode not yet supported") end end - + return (resid, v, n, iparam, ipntr, workd, workl, lworkl, rwork, TOL) end @@ -109,7 +109,7 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::ASCIIString, howmny = "A" select = Array(BlasInt, ncv) info = zeros(BlasInt, 1) - + dmap = x->abs(x) if iparam[7] == 3 # shift-and-invert dmap = x->abs(1./(x-sigma)) @@ -122,7 +122,7 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::ASCIIString, elseif which == "SI" dmap = x->-imag(x) end - + if cmplx d = Array(T, nev+1) @@ -132,7 +132,7 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::ASCIIString, bmat, n, which, nev, TOL, resid, ncv, v, ldv, iparam, ipntr, workd, workl, lworkl, rwork, info) if info[1] != 0; throw(ARPACKException(info[1])); end - + p = sortperm(dmap(d[1:nev]), rev=true) return ritzvec ? (d[p], v[1:n, p],iparam[5],iparam[3],iparam[9],resid) : (d[p],iparam[5],iparam[3],iparam[9],resid) @@ -142,9 +142,9 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::ASCIIString, sigmar = ones(T, 1)*sigma seupd(ritzvec, howmny, select, d, v, ldv, sigmar, bmat, n, which, nev, TOL, resid, ncv, v, ldv, - iparam, ipntr, workd, workl, lworkl, info) + iparam, ipntr, workd, workl, lworkl, info) if info[1] != 0; throw(ARPACKException(info[1])); end - + p = sortperm(dmap(d), rev=true) return ritzvec ? (d[p], v[1:n, p],iparam[5],iparam[3],iparam[9],resid) : (d,iparam[5],iparam[3],iparam[9],resid) @@ -162,7 +162,7 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::ASCIIString, iparam, ipntr, workd, workl, lworkl, info) if info[1] != 0; throw(ARPACKException(info[1])); end evec = complex(Array(T, n, nev+1), Array(T, n, nev+1)) - + j = 1 while j <= nev if di[j] == 0 @@ -182,19 +182,19 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::ASCIIString, error("Arpack unexpected behavior") end end - + d = complex(dr,di) - + if j == nev+1 p = sortperm(dmap(d[1:nev]), rev=true) else p = sortperm(dmap(d), rev=true) p = p[1:nev] end - + return ritzvec ? (d[p], evec[1:n, p],iparam[5],iparam[3],iparam[9],resid) : (d[p],iparam[5],iparam[3],iparam[9],resid) end - + end for (T, saupd_name, seupd_name, naupd_name, neupd_name) in @@ -204,7 +204,7 @@ for (T, saupd_name, seupd_name, naupd_name, neupd_name) in function naupd(ido, bmat, n, evtype, nev, TOL::Array{$T}, resid::Array{$T}, ncv, v::Array{$T}, ldv, iparam, ipntr, workd::Array{$T}, workl::Array{$T}, lworkl, info) - + ccall(($(string(naupd_name)), :libarpack), Void, (Ptr{BlasInt}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{$T}, Ptr{$T}, Ptr{BlasInt}, Ptr{$T}, Ptr{BlasInt}, @@ -229,9 +229,9 @@ for (T, saupd_name, seupd_name, naupd_name, neupd_name) in sizeof(howmny), sizeof(bmat), sizeof(evtype)) end - function saupd(ido, bmat, n, which, nev, TOL::Array{$T}, resid::Array{$T}, ncv, v::Array{$T}, ldv, + function saupd(ido, bmat, n, which, nev, TOL::Array{$T}, resid::Array{$T}, ncv, v::Array{$T}, ldv, iparam, ipntr, workd::Array{$T}, workl::Array{$T}, lworkl, info) - + ccall(($(string(saupd_name)), :libarpack), Void, (Ptr{BlasInt}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{$T}, Ptr{$T}, Ptr{BlasInt}, Ptr{$T}, Ptr{BlasInt}, @@ -243,7 +243,7 @@ for (T, saupd_name, seupd_name, naupd_name, neupd_name) in function seupd(rvec, howmny, select, d, z, ldz, sigma, bmat, n, evtype, nev, TOL::Array{$T}, resid::Array{$T}, ncv, v::Array{$T}, ldv, - iparam, ipntr, workd::Array{$T}, workl::Array{$T}, lworkl, info) + iparam, ipntr, workd::Array{$T}, workl::Array{$T}, lworkl, info) ccall(($(string(seupd_name)), :libarpack), Void, (Ptr{BlasInt}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{$T}, Ptr{$T}, Ptr{BlasInt}, Ptr{$T}, @@ -264,9 +264,9 @@ for (T, TR, naupd_name, neupd_name) in @eval begin function naupd(ido, bmat, n, evtype, nev, TOL::Array{$TR}, resid::Array{$T}, ncv, v::Array{$T}, ldv, - iparam, ipntr, workd::Array{$T}, workl::Array{$T}, lworkl, + iparam, ipntr, workd::Array{$T}, workl::Array{$T}, lworkl, rwork::Array{$TR}, info) - + ccall(($(string(naupd_name)), :libarpack), Void, (Ptr{BlasInt}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{$TR}, Ptr{$T}, Ptr{BlasInt}, Ptr{$T}, Ptr{BlasInt}, @@ -279,7 +279,7 @@ for (T, TR, naupd_name, neupd_name) in function neupd(rvec, howmny, select, d, z, ldz, sigma, workev::Array{$T}, bmat, n, evtype, nev, TOL::Array{$TR}, resid::Array{$T}, ncv, v::Array{$T}, ldv, - iparam, ipntr, workd::Array{$T}, workl::Array{$T}, lworkl, + iparam, ipntr, workd::Array{$T}, workl::Array{$T}, lworkl, rwork::Array{$TR}, info) ccall(($(string(neupd_name)), :libarpack), Void, @@ -289,7 +289,7 @@ for (T, TR, naupd_name, neupd_name) in Ptr{BlasInt}, Ptr{$T}, Ptr{$T}, Ptr{BlasInt}, Ptr{$TR}, Ptr{BlasInt}), &rvec, howmny, select, d, z, &ldz, sigma, workev, bmat, &n, evtype, &nev, TOL, resid, &ncv, v, &ldv, - iparam, ipntr, workd, workl, &lworkl, rwork, info) + iparam, ipntr, workd, workl, &lworkl, rwork, info) end diff --git a/base/linalg/blas.jl b/base/linalg/blas.jl index 7c9329b014f58..dfcaa31ae8501 100644 --- a/base/linalg/blas.jl +++ b/base/linalg/blas.jl @@ -276,11 +276,11 @@ for (fname, elty) in ((:dgemv_,:Float64), m,n = size(A,1),size(A,2) length(X) == (trans == 'N' ? n : m) && length(Y) == (trans == 'N' ? m : n) || throw(DimensionMismatch("")) ccall(($(blasfunc(fname)), libblas), Void, - (Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, + (Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}), - &trans, &size(A,1), &size(A,2), &alpha, - A, &max(1,stride(A,2)), X, &stride(X,1), + &trans, &size(A,1), &size(A,2), &alpha, + A, &max(1,stride(A,2)), X, &stride(X,1), &beta, Y, &stride(Y,1)) Y end @@ -308,12 +308,12 @@ for (fname, elty) in ((:dgbmv_,:Float64), # DOUBLE PRECISION A(LDA,*),X(*),Y(*) function gbmv!(trans::BlasChar, m::Integer, kl::Integer, ku::Integer, alpha::($elty), A::StridedMatrix{$elty}, x::StridedVector{$elty}, beta::($elty), y::StridedVector{$elty}) ccall(($(blasfunc(fname)), libblas), Void, - (Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, - Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, - Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, + (Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, + Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}), - &trans, &m, &size(A,2), &kl, - &ku, &alpha, A, &max(1,stride(A,2)), + &trans, &m, &size(A,2), &kl, + &ku, &alpha, A, &max(1,stride(A,2)), x, &stride(x,1), &beta, y, &stride(y,1)) y end @@ -347,11 +347,11 @@ for (fname, elty) in ((:dsymv_,:Float64), if m != n throw(DimensionMismatch("Matrix A is $m by $n but must be square")) end if m != length(x) || m != length(y) throw(DimensionMismatch("")) end ccall(($(blasfunc(fname)), libblas), Void, - (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, - Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, + (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, + Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}), - &uplo, &n, &alpha, A, - &max(1,stride(A,2)), x, &stride(x,1), &beta, + &uplo, &n, &alpha, A, + &max(1,stride(A,2)), x, &stride(x,1), &beta, y, &stride(y,1)) y end @@ -408,10 +408,10 @@ for (fname, elty) in ((:dsbmv_,:Float64), # DOUBLE PRECISION A(LDA,*),X(*),Y(*) function sbmv!(uplo::BlasChar, k::Integer, alpha::($elty), A::StridedMatrix{$elty}, x::StridedVector{$elty}, beta::($elty), y::StridedVector{$elty}) ccall(($(blasfunc(fname)), libblas), Void, - (Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, - Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, + (Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, + Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}), - &uplo, &size(A,2), &k, &alpha, + &uplo, &size(A,2), &k, &alpha, A, &max(1,stride(A,2)), x, &stride(x,1), &beta, y, &stride(y,1)) y @@ -446,7 +446,7 @@ for (fname, elty) in ((:dtrmv_,:Float64), ccall(($(blasfunc(fname)), libblas), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), - &uplo, &trans, &diag, &n, + &uplo, &trans, &diag, &n, A, &max(1,stride(A,2)), x, &max(1,stride(x, 1))) x end @@ -473,7 +473,7 @@ for (fname, elty) in ((:dtrsv_,:Float64), ccall(($(blasfunc(fname)), libblas), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), - &uplo, &trans, &diag, &n, + &uplo, &trans, &diag, &n, A, &max(1,stride(A,2)), x, &1) x end @@ -494,11 +494,11 @@ for (fname, elty) in ((:dger_,:Float64), m == length(x) || throw(DimensionMismatch("")) n == length(y) || throw(DimensionMismatch("")) ccall(($(blasfunc(fname)), libblas), Void, - (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, - Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, + (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, + Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), - &m, &n, &α, x, - &1, y, &1, A, + &m, &n, &α, x, + &1, y, &1, A, &max(1,stride(A,2))) A end @@ -517,7 +517,7 @@ for (fname, elty) in ((:dsyr_,:Float64), ccall(($(blasfunc(fname)), libblas), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), - &uplo, &n, &α, x, + &uplo, &n, &α, x, &1, A, &max(1,stride(A,2))) A end @@ -534,7 +534,7 @@ for (fname, elty) in ((:zher_,:Complex128), ccall(($(blasfunc(fname)), libblas), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), - &uplo, &n, &α, x, + &uplo, &n, &α, x, &1, A, &max(1,stride(A,2))) A end @@ -567,13 +567,13 @@ for (gemm, elty) in throw(DimensionMismatch("")) end ccall(($(blasfunc(gemm)), libblas), Void, - (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, - Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, - Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, + (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, + Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}), - &transA, &transB, &m, &n, + &transA, &transB, &m, &n, &k, &alpha, A, &max(1,stride(A,2)), - B, &max(1,stride(B,2)), &beta, C, + B, &max(1,stride(B,2)), &beta, C, &max(1,stride(C,2))) C end @@ -604,11 +604,11 @@ for (mfname, elty) in ((:dsymm_,:Float64), j = chksquare(A) if j != (side == 'L' ? m : n) || size(B,2) != n throw(DimensionMismatch("")) end ccall(($(blasfunc(mfname)), libblas), Void, - (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, - Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, + (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}), - &side, &uplo, &m, &n, - &alpha, A, &max(1,stride(A,2)), B, + &side, &uplo, &m, &n, + &alpha, A, &max(1,stride(A,2)), B, &max(1,stride(B,2)), &beta, C, &max(1,stride(C,2))) C end @@ -642,11 +642,11 @@ for (fname, elty) in ((:dsyrk_,:Float64), if nn != n throw(DimensionMismatch("syrk!")) end k = size(A, trans == 'N' ? 2 : 1) ccall(($(blasfunc(fname)), libblas), Void, - (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, - Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, + (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}), - &uplo, &trans, &n, &k, - &alpha, A, &max(1,stride(A,2)), &beta, + &uplo, &trans, &n, &k, + &alpha, A, &max(1,stride(A,2)), &beta, C, &max(1,stride(C,2))) C end @@ -675,11 +675,11 @@ for (fname, elty) in ((:zherk_,:Complex128), (:cherk_,:Complex64)) n == size(A, trans == 'N' ? 1 : 2) || throw(DimensionMismatch("herk!")) k = size(A, trans == 'N' ? 2 : 1) ccall(($(blasfunc(fname)), libblas), Void, - (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, - Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, + (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}), - &uplo, &trans, &n, &k, - &alpha, A, &max(1,stride(A,2)), &beta, + &uplo, &trans, &n, &k, + &alpha, A, &max(1,stride(A,2)), &beta, C, &max(1,stride(C,2))) C end @@ -698,7 +698,7 @@ for (fname, elty) in ((:dsyr2k_,:Float64), (:csyr2k_,:Complex64)) @eval begin # SUBROUTINE DSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC) - # + # # .. Scalar Arguments .. # REAL PRECISION ALPHA,BETA # INTEGER K,LDA,LDB,LDC,N @@ -706,19 +706,19 @@ for (fname, elty) in ((:dsyr2k_,:Float64), # .. # .. Array Arguments .. # REAL PRECISION A(LDA,*),B(LDB,*),C(LDC,*) - function syr2k!(uplo::BlasChar, trans::BlasChar, - alpha::($elty), A::StridedVecOrMat{$elty}, B::StridedVecOrMat{$elty}, + function syr2k!(uplo::BlasChar, trans::BlasChar, + alpha::($elty), A::StridedVecOrMat{$elty}, B::StridedVecOrMat{$elty}, beta::($elty), C::StridedMatrix{$elty}) n = chksquare(C) nn = size(A, trans == 'N' ? 1 : 2) if nn != n throw(DimensionMismatch("syr2k!")) end k = size(A, trans == 'N' ? 2 : 1) ccall(($(blasfunc(fname)), libblas), Void, - (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, - Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, + (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}), - &uplo, &trans, &n, &k, - &alpha, A, &max(1,stride(A,2)), B, &max(1,stride(B,2)), &beta, + &uplo, &trans, &n, &k, + &alpha, A, &max(1,stride(A,2)), B, &max(1,stride(B,2)), &beta, C, &max(1,stride(C,2))) C end @@ -734,7 +734,7 @@ syr2k(uplo::BlasChar, trans::BlasChar, A::StridedVecOrMat, B::StridedVecOrMat) = for (fname, elty1, elty2) in ((:zher2k_,:Complex128,:Float64), (:cher2k_,:Complex64,:Float32)) @eval begin # SUBROUTINE CHER2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC) - # + # # .. Scalar Arguments .. # COMPLEX ALPHA # REAL BETA @@ -743,18 +743,18 @@ for (fname, elty1, elty2) in ((:zher2k_,:Complex128,:Float64), (:cher2k_,:Comple # .. # .. Array Arguments .. # COMPLEX A(LDA,*),B(LDB,*),C(LDC,*) - function her2k!(uplo::BlasChar, trans::BlasChar, alpha::($elty1), + function her2k!(uplo::BlasChar, trans::BlasChar, alpha::($elty1), A::StridedVecOrMat{$elty1}, B::StridedVecOrMat{$elty1}, beta::($elty2), C::StridedMatrix{$elty1}) n = chksquare(C) n == size(A, trans == 'N' ? 1 : 2) || throw(DimensionMismatch("her2k!")) k = size(A, trans == 'N' ? 2 : 1) ccall(($(blasfunc(fname)), libblas), Void, - (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, - Ptr{$elty1}, Ptr{$elty1}, Ptr{BlasInt}, Ptr{$elty1}, Ptr{BlasInt}, + (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, + Ptr{$elty1}, Ptr{$elty1}, Ptr{BlasInt}, Ptr{$elty1}, Ptr{BlasInt}, Ptr{$elty2}, Ptr{$elty1}, Ptr{BlasInt}), - &uplo, &trans, &n, &k, - &alpha, A, &max(1,stride(A,2)), B, &max(1,stride(B,2)), + &uplo, &trans, &n, &k, + &alpha, A, &max(1,stride(A,2)), B, &max(1,stride(B,2)), &beta, C, &max(1,stride(C,2))) C end @@ -809,11 +809,11 @@ for (mmname, smname, elty) in k = chksquare(A) k==(side == 'L' ? m : n) || throw(DimensionMismatch("size of A is $n, size(B)=($m,$n) and transa='$transa'")) ccall(($(blasfunc(smname)), libblas), Void, - (Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, - Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, + (Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, + Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), - &side, &uplo, &transa, &diag, - &m, &n, &alpha, A, + &side, &uplo, &transa, &diag, + &m, &n, &alpha, A, &max(1,stride(A,2)), B, &max(1,stride(B,2))) B end @@ -825,7 +825,7 @@ end end # module -function copy!{T<:BlasFloat,Ti<:Integer}(dest::Array{T}, rdest::Union(UnitRange{Ti},Range{Ti}), +function copy!{T<:BlasFloat,Ti<:Integer}(dest::Array{T}, rdest::Union(UnitRange{Ti},Range{Ti}), src::Array{T}, rsrc::Union(UnitRange{Ti},Range{Ti})) if minimum(rdest) < 1 || maximum(rdest) > length(dest) || minimum(rsrc) < 1 || maximum(rsrc) > length(src) throw(BoundsError()) diff --git a/base/linalg/cholmod.jl b/base/linalg/cholmod.jl index 3deb151f03ede..ab592b78444aa 100644 --- a/base/linalg/cholmod.jl +++ b/base/linalg/cholmod.jl @@ -12,7 +12,7 @@ export # types etree using Base.LinAlg.UMFPACK # for decrement, increment, etc. - + import Base: (*), convert, copy, ctranspose, eltype, findnz, getindex, hcat, isvalid, nnz, show, size, sort!, transpose, vcat @@ -34,16 +34,16 @@ else end const chm_com_sz = ccall((:jl_cholmod_common_size,:libsuitesparse_wrapper),Int,()) const chm_com = fill(0xff, chm_com_sz) -const chm_l_com = fill(0xff, chm_com_sz) +const chm_l_com = fill(0xff, chm_com_sz) ## chm_com and chm_l_com must be initialized at runtime because they contain pointers -## to functions in libc.so, whose addresses can change +## to functions in libc.so, whose addresses can change function cmn(::Type{Int32}) if isnan(reinterpret(Float64,chm_com[1:8])[1]) @isok ccall((:cholmod_start, :libcholmod), Cint, (Ptr{UInt8},), chm_com) end chm_com end -function cmn(::Type{Int64}) +function cmn(::Type{Int64}) if isnan(reinterpret(Float64,chm_l_com[1:8])[1]) @isok ccall((:cholmod_l_start, :libcholmod), Cint, (Ptr{UInt8},), chm_l_com) end @@ -57,7 +57,7 @@ type CholmodException <: Exception end ## macro to generate the name of the C function according to the integer type macro chm_nm(nm,typ) string("cholmod_", eval(typ) == Int64 ? "l_" : "", nm) end - + ### A way of examining some of the fields in chm_com ### Probably better to make this a Dict{ASCIIString,Tuple} and ### save the offsets and the lengths and the types. Then the names can be checked. @@ -102,7 +102,7 @@ end function set_chm_prt_lev(cm::Array{UInt8}, lev::Integer) # can probably be removed cm[(1:4) + chm_com_offsets[13]] = reinterpret(UInt8, [int32(lev)]) end - + ## cholmod_dense pointers passed to or returned from C functions are of Julia type ## Ptr{c_CholmodDense}. The CholmodDense type contains a c_CholmodDense object and other ## fields then ensure the memory pointed to is freed when it should be and not before. @@ -321,7 +321,7 @@ function CholmodDense!{T<:CHMVTypes}(aa::VecOrMat{T}) # uses the memory from Jul length(size(aa)) == 2 ? aa : reshape(aa, (m,n))) end -## The CholmodDense constructor copies the contents +## The CholmodDense constructor copies the contents function CholmodDense{T<:CHMVTypes}(aa::VecOrMat{T}) m = size(aa,1); n = size(aa,2) acp = length(size(aa)) == 2 ? copy(aa) : reshape(copy(aa), (m,n)) @@ -387,7 +387,7 @@ function copy{Tv<:CHMVTypes}(B::CholmodDense{Tv}) end function norm{Tv<:CHMVTypes}(D::CholmodDense{Tv},p::Real=1) - ccall((:cholmod_norm_dense, :libcholmod), Float64, + ccall((:cholmod_norm_dense, :libcholmod), Float64, (Ptr{c_CholmodDense{Tv}}, Cint, Ptr{UInt8}), &D.c, p == 1 ? 1 :(p == Inf ? 1 : throw(ArgumentError("p must be 1 or Inf"))),cmn(Int32)) end @@ -402,7 +402,7 @@ function CholmodSparse!{Tv<:CHMVTypes,Ti<:CHMITypes}(colpt::Vector{Ti}, if bb != 0 && bb != 1 throw(DimensionMismatch("colpt[1] is $bb, must be 0 or 1")) end if any(diff(colpt) .< 0) throw(ArgumentError("elements of colpt must be non-decreasing")) end if length(colpt) != n + 1 throw(DimensionMismatch("length(colptr) = $(length(colpt)), should be $(n+1)")) end - if bool(bb) # one-based + if bool(bb) # one-based decrement!(colpt) decrement!(rowval) end @@ -456,7 +456,7 @@ CholmodSparse{Tv<:CHMVTypes}(D::CholmodDense{Tv}) = CholmodSparse(D,1) # default function CholmodTriplet{Tv<:CHMVTypes,Ti<:CHMITypes}(tp::Ptr{c_CholmodTriplet{Tv,Ti}}) ctp = unsafe_load(tp) i = pointer_to_array(ctp.i, (ctp.nnz,), true) - j = pointer_to_array(ctp.j, (ctp.nnz,), true) + j = pointer_to_array(ctp.j, (ctp.nnz,), true) x = pointer_to_array(ctp.x, (ctp.x == C_NULL ? 0 : ctp.nnz), true) ct = CholmodTriplet{Tv,Ti}(ctp, i, j, x) c_free(tp) @@ -574,7 +574,7 @@ for Ti in (:Int32,:Int64) (Ptr{c_CholmodFactor{Tv,$Ti}},Ptr{UInt8}), &L.c,cmn($Ti))) end - cm = cmn($Ti) + cm = cmn($Ti) Lcll = ccall((@chm_nm "copy_factor" $Ti ,:libcholmod), Ptr{c_CholmodFactor{Tv,$Ti}}, (Ptr{c_CholmodFactor{Tv,$Ti}},Ptr{UInt8}), @@ -784,7 +784,7 @@ for Ti in (:Int32,:Int64) end function norm{Tv<:CHMVTypes}(A::CholmodSparse{Tv,$Ti},p::Real) ccall((@chm_nm "norm_sparse" $Ti - , :libcholmod), Float64, + , :libcholmod), Float64, (Ptr{c_CholmodSparse{Tv,$Ti}}, Cint, Ptr{UInt8}), &A.c,p == 1 ? 1 :(p == Inf ? 1 : throw(ArgumentError("p must be 1 or Inf"))),cmn($Ti)) end @@ -861,7 +861,7 @@ end function Ac_ldiv_B{Tv<:CHMVTypes,Ti<:CHMITypes}(L::CholmodFactor{Tv,Ti},B::SparseMatrixCSC{Tv,Ti}) sparse!(solve(L,CholmodSparse(B),CHOLMOD_A)) end - + function Ac_mul_B{Tv<:CHMVTypes}(A::CholmodSparse{Tv},B::CholmodDense{Tv}) chm_sdmult(A,true,1.,0.,B) end @@ -875,7 +875,7 @@ function At_mul_B{Tv<:Union(Float32,Float64),Ti<:CHMITypes}(A::CholmodSparse{Tv, end cholfact{T<:CHMVTypes}(A::CholmodSparse{T},beta::T) = cholfact(A,beta,false) -cholfact(A::CholmodSparse) = cholfact(A,false) +cholfact(A::CholmodSparse) = cholfact(A,false) cholfact(A::SparseMatrixCSC,ll::Bool) = cholfact(CholmodSparse(A),ll) cholfact(A::SparseMatrixCSC) = cholfact(CholmodSparse(A),false) function cholfact!{T<:CHMVTypes}(L::CholmodFactor{T},A::CholmodSparse{T},beta::Number) @@ -914,7 +914,7 @@ end scale{T<:CHMVTypes}(A::CholmodSparse{T},b::Vector{T}) = scale!(copy(A), b) norm(A::CholmodSparse) = norm(A,1) - + show(io::IO,L::CholmodFactor) = chm_print(L,int32(4),"") show(io::IO,A::CholmodSparse) = chm_print(A,int32(4),"") @@ -1032,7 +1032,7 @@ function sparse(A::CholmodSparse) end function sparse!(A::CholmodSparse) SparseMatrixCSC(A.c.m, A.c.n, increment!(A.colptr0), increment!(A.rowval0), A.nzval) -end +end sparse(L::CholmodFactor) = sparse!(CholmodSparse(L)) sparse(D::CholmodDense) = sparse!(CholmodSparse(D)) sparse(T::CholmodTriplet) = sparse!(CholmodSparse(T)) diff --git a/base/linalg/cholmod_h.jl b/base/linalg/cholmod_h.jl index 944893d95c7d8..52c3572f9f966 100644 --- a/base/linalg/cholmod_h.jl +++ b/base/linalg/cholmod_h.jl @@ -3,24 +3,24 @@ const CHOLMOD_TRUE = int32(1) const CHOLMOD_FALSE = int32(0) ## itype defines the types of integer used: -const CHOLMOD_INT = int32(0) # all integer arrays are int -const CHOLMOD_LONG = int32(2) # all integer arrays are UF_long +const CHOLMOD_INT = int32(0) # all integer arrays are int +const CHOLMOD_LONG = int32(2) # all integer arrays are UF_long ityp(::Type{Int32}) = CHOLMOD_INT ityp(::Type{Int64}) = CHOLMOD_LONG ## dtype defines what the numerical type is (double or float): -const CHOLMOD_DOUBLE = int32(0) # all numerical values are double -const CHOLMOD_SINGLE = int32(1) # all numerical values are float +const CHOLMOD_DOUBLE = int32(0) # all numerical values are double +const CHOLMOD_SINGLE = int32(1) # all numerical values are float dtyp(::Type{Float32}) = CHOLMOD_SINGLE dtyp(::Type{Float64}) = CHOLMOD_DOUBLE dtyp(::Type{Complex64}) = CHOLMOD_SINGLE dtyp(::Type{Complex128}) = CHOLMOD_DOUBLE ## xtype defines the kind of numerical values used: -const CHOLMOD_PATTERN = int32(0) # pattern only, no numerical values -const CHOLMOD_REAL = int32(1) # a real matrix -const CHOLMOD_COMPLEX = int32(2) # a complex matrix (ANSI C99 compatible) -const CHOLMOD_ZOMPLEX = int32(3) # a complex matrix (MATLAB compatible) +const CHOLMOD_PATTERN = int32(0) # pattern only, no numerical values +const CHOLMOD_REAL = int32(1) # a real matrix +const CHOLMOD_COMPLEX = int32(2) # a complex matrix (ANSI C99 compatible) +const CHOLMOD_ZOMPLEX = int32(3) # a complex matrix (MATLAB compatible) xtyp(::Type{Float32}) = CHOLMOD_REAL xtyp(::Type{Float64}) = CHOLMOD_REAL xtyp(::Type{Complex64}) = CHOLMOD_COMPLEX @@ -33,12 +33,12 @@ const CHOLMOD_COL = int32(2) # A = A*diag(s) const CHOLMOD_SYM = int32(3) # A = diag(s)*A*diag(s) ## Types of systems to solve -const CHOLMOD_A = int32(0) # solve Ax=b -const CHOLMOD_LDLt = int32(1) # solve LDL'x=b -const CHOLMOD_LD = int32(2) # solve LDx=b -const CHOLMOD_DLt = int32(3) # solve DL'x=b -const CHOLMOD_L = int32(4) # solve Lx=b -const CHOLMOD_Lt = int32(5) # solve L'x=b -const CHOLMOD_D = int32(6) # solve Dx=b -const CHOLMOD_P = int32(7) # permute x=Px -const CHOLMOD_Pt = int32(8) # permute x=P'x +const CHOLMOD_A = int32(0) # solve Ax=b +const CHOLMOD_LDLt = int32(1) # solve LDL'x=b +const CHOLMOD_LD = int32(2) # solve LDx=b +const CHOLMOD_DLt = int32(3) # solve DL'x=b +const CHOLMOD_L = int32(4) # solve Lx=b +const CHOLMOD_Lt = int32(5) # solve L'x=b +const CHOLMOD_D = int32(6) # solve Dx=b +const CHOLMOD_P = int32(7) # permute x=Px +const CHOLMOD_Pt = int32(8) # permute x=P'x diff --git a/base/linalg/dense.jl b/base/linalg/dense.jl index dfdad12f5f068..4a0270f16f929 100644 --- a/base/linalg/dense.jl +++ b/base/linalg/dense.jl @@ -54,10 +54,10 @@ function norm{T<:BlasFloat, TI<:Integer}(x::StridedVector{T}, rx::Union(UnitRang BLAS.nrm2(length(rx), pointer(x)+(first(rx)-1)*sizeof(T), step(rx)) end -vecnorm1{T<:BlasReal}(x::Union(Array{T},StridedVector{T})) = +vecnorm1{T<:BlasReal}(x::Union(Array{T},StridedVector{T})) = length(x) < ASUM_CUTOFF ? generic_vecnorm1(x) : BLAS.asum(x) -vecnorm2{T<:BlasFloat}(x::Union(Array{T},StridedVector{T})) = +vecnorm2{T<:BlasFloat}(x::Union(Array{T},StridedVector{T})) = length(x) < NRM2_CUTOFF ? generic_vecnorm2(x) : BLAS.nrm2(x) function triu!(M::AbstractMatrix, k::Integer) @@ -121,7 +121,7 @@ function diagm{T}(v::AbstractVector{T}, k::Integer=0) A = zeros(T,n,n) A[diagind(A,k)] = v A -end +end diagm(x::Number) = (X = Array(typeof(x),1,1); X[1,1] = x; X) @@ -147,8 +147,8 @@ function kron{T,S}(a::Matrix{T}, b::Matrix{S}) R end -kron(a::Number, b::Union(Number, Vector, Matrix)) = a * b -kron(a::Union(Vector, Matrix), b::Number) = a * b +kron(a::Number, b::Union(Number, Vector, Matrix)) = a * b +kron(a::Union(Vector, Matrix), b::Number) = a * b kron(a::Vector, b::Vector)=vec(kron(reshape(a,length(a),1),reshape(b,length(b),1))) kron(a::Matrix, b::Vector)=kron(a,reshape(b,length(b),1)) kron(a::Vector, b::Matrix)=kron(reshape(a,length(a),1),b) @@ -156,8 +156,8 @@ kron(a::Vector, b::Matrix)=kron(reshape(a,length(a),1),b) ^(A::Matrix, p::Integer) = p < 0 ? inv(A^-p) : Base.power_by_squaring(A,p) function ^(A::Matrix, p::Number) - isinteger(p) && return A^integer(real(p)) - + isinteger(p) && return A^integer(real(p)) + chksquare(A) v, X = eig(A) any(v.<0) && (v = complex(v)) @@ -263,7 +263,7 @@ function expm!{T<:BlasFloat}(A::StridedMatrix{T}) X = V + U LAPACK.gesv!(V-U, X) - + if s > 0 # squaring to reverse dividing by power of 2 for t=1:si X *= X end end @@ -322,9 +322,9 @@ function inv{S}(A::StridedMatrix{S}) Ac = convert(AbstractMatrix{T}, A) if istriu(Ac) Ai = inv(Triangular(A, :U, false)) - elseif istril(Ac) + elseif istril(Ac) Ai = inv(Triangular(A, :L, false)) - else + else Ai = inv(lufact(Ac)) end return convert(typeof(Ac), Ai) @@ -380,7 +380,7 @@ function factorize{T}(A::Matrix{T}) end if utri1 if (herm & (T <: Complex)) | sym - try + try return ldltfact!(SymTridiagonal(diag(A), diag(A, -1))) end end @@ -409,7 +409,7 @@ function (\)(A::StridedMatrix, B::StridedVecOrMat) m, n = size(A) if m == n if istril(A) - return istriu(A) ? \(Diagonal(A),B) : \(Triangular(A, :L),B) + return istriu(A) ? \(Diagonal(A),B) : \(Triangular(A, :L),B) end istriu(A) && return \(Triangular(A, :U),B) return \(lufact(A),B) @@ -441,7 +441,7 @@ function null{T}(A::StridedMatrix{T}) end null(a::StridedVector) = null(reshape(a, length(a), 1)) -function cond(A::StridedMatrix, p::Real=2) +function cond(A::StridedMatrix, p::Real=2) if p == 2 v = svdvals(A) maxv = maximum(v) @@ -476,4 +476,4 @@ function lyap{T<:BlasFloat}(A::StridedMatrix{T},C::StridedMatrix{T}) end lyap{T<:Integer}(A::StridedMatrix{T},C::StridedMatrix{T}) = lyap(float(A), float(C)) lyap{T<:Number}(a::T, c::T) = -c/(2a) - + diff --git a/base/linalg/factorization.jl b/base/linalg/factorization.jl index d43917ff5882d..5ee984f8b582a 100644 --- a/base/linalg/factorization.jl +++ b/base/linalg/factorization.jl @@ -113,7 +113,7 @@ immutable QRPackedQ{T} <: AbstractMatrix{T} factors::Matrix{T} τ::Vector{T} end -immutable QRCompactWYQ{S} <: AbstractMatrix{S} +immutable QRCompactWYQ{S} <: AbstractMatrix{S} factors::Matrix{S} T::Matrix{S} end @@ -451,7 +451,7 @@ end function eigfact!{T<:BlasComplex}(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) n = size(A, 2) n == 0 && return Eigen(zeros(T, 0), zeros(T, 0, 0)) - ishermitian(A) && return eigfact!(Hermitian(A)) + ishermitian(A) && return eigfact!(Hermitian(A)) return Eigen(LAPACK.geevx!(permute ? (scale ? 'B' : 'P') : (scale ? 'S' : 'N'), 'N', 'V', 'N', A)[[2,4]]...) end eigfact{T}(A::AbstractMatrix{T}, args...; kwargs...) = (S = promote_type(Float32,typeof(one(T)/norm(one(T)))); S != T ? eigfact!(convert(AbstractMatrix{S}, A), args...; kwargs...) : eigfact!(copy(A), args...; kwargs...)) @@ -703,16 +703,16 @@ end convert{T}(::Type{Factorization{T}}, F::Factorization{T}) = F inv{T}(F::Factorization{T}) = A_ldiv_B!(F, eye(T, size(F,1))) function \{TF<:Number,TB<:Number,N}(F::Factorization{TF}, B::AbstractArray{TB,N}) - TFB = typeof(one(TF)/one(TB)) + TFB = typeof(one(TF)/one(TB)) A_ldiv_B!(convert(Factorization{TFB}, F), TB == TFB ? copy(B) : convert(AbstractArray{TFB,N}, B)) end function Ac_ldiv_B{TF<:Number,TB<:Number,N}(F::Factorization{TF}, B::AbstractArray{TB,N}) - TFB = typeof(one(TF)/one(TB)) + TFB = typeof(one(TF)/one(TB)) Ac_ldiv_B!(convert(Factorization{TFB}, F), TB == TFB ? copy(B) : convert(AbstractArray{TFB,N}, B)) end function At_ldiv_B{TF<:Number,TB<:Number,N}(F::Factorization{TF}, B::AbstractArray{TB,N}) - TFB = typeof(one(TF)/one(TB)) + TFB = typeof(one(TF)/one(TB)) At_ldiv_B!(convert(Factorization{TFB}, F), TB == TFB ? copy(B) : convert(AbstractArray{TFB,N}, B)) end diff --git a/base/linalg/lapack.jl b/base/linalg/lapack.jl index 10677bf91acbf..6b0a759bacebb 100644 --- a/base/linalg/lapack.jl +++ b/base/linalg/lapack.jl @@ -262,16 +262,16 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{BlasInt}), - &m, &n, A, &lda, - jpvt, tau, work, &lwork, + &m, &n, A, &lda, + jpvt, tau, work, &lwork, rwork, info) else ccall(($(blasfunc(geqp3)), liblapack), Void, (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), - &m, &n, A, &lda, - jpvt, tau, work, + &m, &n, A, &lda, + jpvt, tau, work, &lwork, info) end @lapackerror @@ -293,10 +293,10 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty if n > 0 info = Array(BlasInt, 1) ccall(($(blasfunc(geqrt)), liblapack), Void, - (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, + (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), - &m, &n, &nb, A, + &m, &n, &nb, A, &lda, T, &max(1,stride(T,2)), work, info) @lapackerror @@ -409,14 +409,14 @@ function geqp3!{T<:BlasFloat}(A::StridedMatrix{T}) end ## Complete orthogonaliztion tools -for (tzrzf, ormrz, elty) in +for (tzrzf, ormrz, elty) in ((:dtzrzf_,:dormrz_,:Float64), (:stzrzf_,:sormrz_,:Float32), (:ztzrzf_,:zunmrz_,:Complex128), (:ctzrzf_,:cunmrz_,:Complex64)) @eval begin # * SUBROUTINE ZTZRZF( M, N, A, LDA, TAU, WORK, LWORK, INFO ) - # 22 * + # 22 * # 23 * .. Scalar Arguments .. # 24 * INTEGER INFO, LDA, LWORK, M, N # 25 * .. @@ -434,7 +434,7 @@ for (tzrzf, ormrz, elty) in ccall(($(blasfunc(tzrzf)), liblapack), Void, (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), - &m, &n, A, &lda, + &m, &n, A, &lda, tau, work, &lwork, info) if i == 1 lwork = blas_int(real(work[1])) @@ -446,7 +446,7 @@ for (tzrzf, ormrz, elty) in end # 21 * SUBROUTINE ZUNMRZ( SIDE, TRANS, M, N, K, L, A, LDA, TAU, C, LDC, # 22 * WORK, LWORK, INFO ) - # 23 * + # 23 * # 24 * .. Scalar Arguments .. # 25 * CHARACTER SIDE, TRANS # 26 * INTEGER INFO, K, L, LDA, LDC, LWORK, M, N @@ -468,9 +468,9 @@ for (tzrzf, ormrz, elty) in Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), - &side, &trans, &m, &n, - &k, &l, A, &lda, - tau, C, &ldc, work, + &side, &trans, &m, &n, + &k, &l, A, &lda, + tau, C, &ldc, work, &lwork, info) if i == 1 lwork = blas_int(real(work[1])) @@ -603,7 +603,7 @@ for (gesvx, elty) in # SUBROUTINE DGESVX( FACT, TRANS, N, NRHS, A, LDA, AF, LDAF, IPIV, # EQUED, R, C, B, LDB, X, LDX, RCOND, FERR, BERR, # WORK, IWORK, INFO ) - # + # # .. Scalar Arguments .. # CHARACTER EQUED, FACT, TRANS # INTEGER INFO, LDA, LDAF, LDB, LDX, N, NRHS @@ -613,7 +613,7 @@ for (gesvx, elty) in # INTEGER IPIV( * ), IWORK( * ) # DOUBLE PRECISION A( LDA, * ), AF( LDAF, * ), B( LDB, * ), # $ BERR( * ), C( * ), FERR( * ), R( * ), - # $ WORK( * ), X( LDX, * + # $ WORK( * ), X( LDX, * # function gesvx!(fact::BlasChar, trans::BlasChar, A::StridedMatrix{$elty}, AF::StridedMatrix{$elty}, ipiv::Vector{BlasInt}, equed::BlasChar, @@ -637,7 +637,7 @@ for (gesvx, elty) in &fact, &trans, &n, &nrhs, A, &lda, AF, &ldaf, ipiv, &equed, R, C, B, &ldb, X, &n, rcond, ferr, berr, work, iwork, info) @lapackerror - if info[1] == n+1 warn("Matrix is singular to working precision.") + if info[1] == n+1 warn("Matrix is singular to working precision.") else @assertnonsingular end #WORK(1) contains the reciprocal pivot growth factor norm(A)/norm(U) @@ -706,7 +706,7 @@ for (gesvx, elty, relty) in end end -for (gelsd, gelsy, elty) in +for (gelsd, gelsy, elty) in ((:dgelsd_,:dgelsy_,:Float64), (:sgelsd_,:sgelsy_,:Float32)) @eval begin @@ -779,9 +779,9 @@ for (gelsd, gelsy, elty) in Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), - &m, &n, &nrhs, A, - &lda, newB, &ldb, jpvt, - &rcond, rnk, work, &lwork, + &m, &n, &nrhs, A, + &lda, newB, &ldb, jpvt, + &rcond, rnk, work, &lwork, info) if i == 1 lwork = blas_int(work[1]) @@ -793,7 +793,7 @@ for (gelsd, gelsy, elty) in end end end -for (gelsd, gelsy, elty, relty) in +for (gelsd, gelsy, elty, relty) in ((:zgelsd_,:zgelsy_,:Complex128,:Float64), (:cgelsd_,:cgelsy_,:Complex64,:Float32)) @eval begin @@ -870,9 +870,9 @@ for (gelsd, gelsy, elty, relty) in Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{BlasInt}), - &m, &n, &nrhs, A, - &lda, newB, &ldb, jpvt, - &rcond, rnk, work, &lwork, + &m, &n, &nrhs, A, + &lda, newB, &ldb, jpvt, + &rcond, rnk, work, &lwork, rwork, info) if i == 1 lwork = blas_int(real(work[1])) @@ -966,7 +966,7 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in if cmplx ccall(($(blasfunc(geev)), liblapack), Void, (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, Ptr{$elty}, - Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, + Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{BlasInt}), &jobvl, &jobvr, &n, A, &max(1,stride(A,2)), W, VL, &n, VR, &n, @@ -1138,11 +1138,11 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in Ptr{$relty}, Ptr{$relty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$relty}, Ptr{BlasInt}, Ptr{BlasInt}), - &jobu, &jobv, &jobq, &m, - &n, &p, k, l, - A, &lda, B, &ldb, - alpha, beta, U, &ldu, - V, &ldv, Q, &ldq, + &jobu, &jobv, &jobq, &m, + &n, &p, k, l, + A, &lda, B, &ldb, + alpha, beta, U, &ldu, + V, &ldv, Q, &ldq, work, rwork, iwork, info) else ccall(($(blasfunc(ggsvd)), liblapack), Void, @@ -1152,11 +1152,11 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in Ptr{$relty}, Ptr{$relty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), - &jobu, &jobv, &jobq, &m, - &n, &p, k, l, - A, &lda, B, &ldb, - alpha, beta, U, &ldu, - V, &ldv, Q, &ldq, + &jobu, &jobv, &jobq, &m, + &n, &p, k, l, + A, &lda, B, &ldb, + alpha, beta, U, &ldu, + V, &ldv, Q, &ldq, work, iwork, info) end @lapackerror @@ -1170,14 +1170,14 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in end end ## Expert driver and generalized eigenvlua problem -for (geevx, ggev, elty) in +for (geevx, ggev, elty) in ((:dgeevx_,:dggev_,:Float64), (:sgeevx_,:sggev_,:Float32)) @eval begin # SUBROUTINE DGEEVX( BALANC, JOBVL, JOBVR, SENSE, N, A, LDA, WR, WI, # VL, LDVL, VR, LDVR, ILO, IHI, SCALE, ABNRM, # RCONDE, RCONDV, WORK, LWORK, IWORK, INFO ) - # + # # .. Scalar Arguments .. # CHARACTER BALANC, JOBVL, JOBVR, SENSE # INTEGER IHI, ILO, INFO, LDA, LDVL, LDVR, LWORK, N @@ -1215,11 +1215,11 @@ for (geevx, ggev, elty) in Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}), - &balanc, &jobvl, &jobvr, &sense, - &n, A, &lda, wr, - wi, VL, &max(1,ldvl), VR, - &max(1,ldvr), ilo, ihi, scale, - abnrm, rconde, rcondv, work, + &balanc, &jobvl, &jobvr, &sense, + &n, A, &lda, wr, + wi, VL, &max(1,ldvl), VR, + &max(1,ldvr), ilo, ihi, scale, + abnrm, rconde, rcondv, work, &lwork, iwork, info) lwork = convert(BlasInt, work[1]) work = Array($elty, lwork) @@ -1261,10 +1261,10 @@ for (geevx, ggev, elty) in Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), - &jobvl, &jobvr, &n, A, - &lda, B, &ldb, alphar, - alphai, beta, vl, &ldvl, - vr, &ldvr, work, &lwork, + &jobvl, &jobvr, &n, A, + &lda, B, &ldb, alphar, + alphai, beta, vl, &ldvl, + vr, &ldvr, work, &lwork, info) if i == 1 lwork = blas_int(work[1]) @@ -1276,14 +1276,14 @@ for (geevx, ggev, elty) in end end end -for (geevx, ggev, elty, relty) in +for (geevx, ggev, elty, relty) in ((:zgeevx_,:zggev_,:Complex128,:Float64), (:cgeevx_,:cggev_,:Complex64,:Float32)) @eval begin # SUBROUTINE ZGEEVX( BALANC, JOBVL, JOBVR, SENSE, N, A, LDA, W, VL, # LDVL, VR, LDVR, ILO, IHI, SCALE, ABNRM, RCONDE, # RCONDV, WORK, LWORK, RWORK, INFO ) - # + # # .. Scalar Arguments .. # CHARACTER BALANC, JOBVL, JOBVR, SENSE # INTEGER IHI, ILO, INFO, LDA, LDVL, LDVR, LWORK, N @@ -1316,15 +1316,15 @@ for (geevx, ggev, elty, relty) in ccall(($(blasfunc(geevx)), liblapack), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, - Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, - Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$relty}, Ptr{$relty}, - Ptr{$relty}, Ptr{$relty}, Ptr{$elty}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, + Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$relty}, Ptr{$relty}, + Ptr{$relty}, Ptr{$relty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{BlasInt}), - &balanc, &jobvl, &jobvr, &sense, - &n, A, &lda, w, - VL, &max(1,ldvl), VR, &max(1,ldvr), - ilo, ihi, scale, abnrm, - rconde, rcondv, work, &lwork, + &balanc, &jobvl, &jobvr, &sense, + &n, A, &lda, w, + VL, &max(1,ldvl), VR, &max(1,ldvr), + ilo, ihi, scale, abnrm, + rconde, rcondv, work, &lwork, rwork, info) lwork = convert(BlasInt, work[1]) work = Array($elty, lwork) @@ -1363,12 +1363,12 @@ for (geevx, ggev, elty, relty) in ccall(($(blasfunc(ggev)), liblapack), Void, (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, - Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, + Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{BlasInt}), - &jobvl, &jobvr, &n, A, - &lda, B, &ldb, alpha, - beta, vl, &ldvl, vr, + &jobvl, &jobvr, &n, A, + &lda, B, &ldb, alpha, + beta, vl, &ldvl, vr, &ldvr, work, &lwork, rwork, info) if i == 1 @@ -1388,7 +1388,7 @@ for (laic1, elty) in (:slaic1_,:Float32)) @eval begin # 21 * SUBROUTINE DLAIC1( JOB, J, X, SEST, W, GAMMA, SESTPR, S, C ) - # 22 * + # 22 * # 23 * .. Scalar Arguments .. # 24 * INTEGER J, JOB # 25 * DOUBLE PRECISION C, GAMMA, S, SEST, SESTPR @@ -1405,8 +1405,8 @@ for (laic1, elty) in (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}), - &job, &j, x, &sest, - w, &gamma, sestpr, s, + &job, &j, x, &sest, + w, &gamma, sestpr, s, c) sestpr[1], s[1], c[1] end @@ -1417,7 +1417,7 @@ for (laic1, elty, relty) in (:claic1_,:Complex64,:Float32)) @eval begin # 21 * SUBROUTINE ZLAIC1( JOB, J, X, SEST, W, GAMMA, SESTPR, S, C ) - # 22 * + # 22 * # 23 * .. Scalar Arguments .. # 24 * INTEGER J, JOB # 25 * DOUBLE PRECISION SEST, SESTPR @@ -1435,8 +1435,8 @@ for (laic1, elty, relty) in (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$relty}, Ptr{$elty}, Ptr{$elty}, Ptr{$relty}, Ptr{$elty}, Ptr{$elty}), - &job, &j, x, &sest, - w, &gamma, sestpr, s, + &job, &j, x, &sest, + w, &gamma, sestpr, s, c) sestpr[1], s[1], c[1] end @@ -1544,7 +1544,7 @@ for (orglq, orgqr, ormlq, ormqr, gemqrt, elty) in Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), &m, &n, &k, A, &max(1,stride(A,2)), tau, work, &lwork, info) @lapackerror - if lwork < 0 + if lwork < 0 lwork = blas_int(real(work[1])) work = Array($elty, lwork) end @@ -1572,11 +1572,11 @@ for (orglq, orgqr, ormlq, ormqr, gemqrt, elty) in ccall(($(blasfunc(orgqr)), liblapack), Void, (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), - &m, &n, &k, A, - &max(1,stride(A,2)), tau, work, &lwork, + &m, &n, &k, A, + &max(1,stride(A,2)), tau, work, &lwork, info) @lapackerror - if lwork < 0 + if lwork < 0 lwork = blas_int(real(work[1])) work = Array($elty, lwork) end @@ -1601,7 +1601,7 @@ for (orglq, orgqr, ormlq, ormqr, gemqrt, elty) in nA = size(A, 2) k = length(tau) if side == 'L' && m != nA throw(DimensionMismatch("")) end - if side == 'R' && n != nA throw(DimensionMismatch("")) end + if side == 'R' && n != nA throw(DimensionMismatch("")) end if (side == 'L' && k > m) || (side == 'R' && k > n) throw(DimensionMismatch("invalid number of reflectors")) end work = Array($elty, 1) lwork = blas_int(-1) @@ -1614,7 +1614,7 @@ for (orglq, orgqr, ormlq, ormqr, gemqrt, elty) in &side, &trans, &m, &n, &k, A, &max(1,stride(A,2)), tau, C, &max(1,stride(C,2)), work, &lwork, info) @lapackerror - if lwork < 0 + if lwork < 0 lwork = blas_int(real(work[1])) work = Array($elty, lwork) end @@ -1635,23 +1635,23 @@ for (orglq, orgqr, ormlq, ormqr, gemqrt, elty) in mA = size(A, 1) k = length(tau) if side == 'L' && m != mA throw(DimensionMismatch("")) end - if side == 'R' && n != mA throw(DimensionMismatch("")) end + if side == 'R' && n != mA throw(DimensionMismatch("")) end if (side == 'L' && k > m) || (side == 'R' && k > n) throw(DimensionMismatch("invalid number of reflectors")) end work = Array($elty, 1) lwork = blas_int(-1) info = Array(BlasInt, 1) for i in 1:2 ccall(($(blasfunc(ormqr)), liblapack), Void, - (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, Ptr{BlasInt}, - Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, - Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, + (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, Ptr{BlasInt}, + Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, + Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), - &side, &trans, &m, &n, + &side, &trans, &m, &n, &k, A, &max(1,stride(A,2)), tau, - C, &max(1, stride(C,2)), work, &lwork, + C, &max(1, stride(C,2)), work, &lwork, info) @lapackerror - if lwork < 0 + if lwork < 0 lwork = blas_int(real(work[1])) work = Array($elty, lwork) end @@ -1779,9 +1779,9 @@ for (posv, potrf, potri, potrs, pstrf, elty, rtyp) in ldb = max(1,stride(B,2)) info = Array(BlasInt, 1) ccall(($(blasfunc(potrs)), liblapack), Void, - (Ptr{BlasChar}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, + (Ptr{BlasChar}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), - &uplo, &n, &nrhs, A, + &uplo, &n, &nrhs, A, &lda, B, &ldb, info) @lapackerror return B @@ -2002,7 +2002,7 @@ for (trcon, trevc, trrfs, elty) in # Extract n, mm = chksquare(T), size(VL, 2) ldt, ldvl, ldvr = stride(T, 2), stride(VL, 2), stride(VR, 2) - + # Check chkstride1(T) @@ -2010,15 +2010,15 @@ for (trcon, trevc, trrfs, elty) in m = Array(BlasInt, 1) work = Array($elty, 3n) info = Array(BlasInt, 1) - + ccall(($(blasfunc(trevc)), liblapack), Void, - (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, Ptr{BlasInt}, - Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, - Ptr{$elty}, Ptr{BlasInt},Ptr{BlasInt}, Ptr{BlasInt}, + (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{BlasInt},Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), - &side, &howmny, select, &n, - T, &ldt, VL, &ldvl, - VR, &ldvr, &mm, m, + &side, &howmny, select, &n, + T, &ldt, VL, &ldvl, + VR, &ldvr, &mm, m, work, info) @lapackerror @@ -2061,7 +2061,7 @@ for (trcon, trevc, trrfs, elty) in iwork = Array(BlasInt, n) info = Array(BlasInt, 1) ccall(($(blasfunc(trrfs)), liblapack), Void, - (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, + (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), &uplo, &trans, &diag, &n, @@ -2114,13 +2114,13 @@ for (trcon, trevc, trrfs, elty, relty) in # LOGICAL SELECT( * ) # DOUBLE PRECISION RWORK( * ) # COMPLEX*16 T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ), - #$ WORK( * ) + #$ WORK( * ) function trevc!(side::Char, howmny::Char, select::Vector{BlasInt}, T::StridedMatrix{$elty}, VL::StridedMatrix{$elty} = similar(T), VR::StridedMatrix{$elty} = similar(T)) # Extract n, mm = chksquare(T), size(VL, 2) ldt, ldvl, ldvr = stride(T, 2), stride(VL, 2), stride(VR, 2) - + # Check chkstride1(T) @@ -2129,15 +2129,15 @@ for (trcon, trevc, trrfs, elty, relty) in work = Array($elty, 2n) rwork = Array($relty, n) info = Array(BlasInt, 1) - + ccall(($(blasfunc(trevc)), liblapack), Void, - (Ptr{Char}, Ptr{Char}, Ptr{BlasInt}, Ptr{BlasInt}, - Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, - Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, + (Ptr{Char}, Ptr{Char}, Ptr{BlasInt}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$relty}, Ptr{BlasInt}), - &side, &howmny, select, &n, - T, &ldt, VL, &ldvl, - VR, &ldvr, &mm, m, + &side, &howmny, select, &n, + T, &ldt, VL, &ldvl, + VR, &ldvr, &mm, m, work, rwork, info) @lapackerror @@ -2180,8 +2180,8 @@ for (trcon, trevc, trrfs, elty, relty) in rwork=Array($relty, n) info=Array(BlasInt, 1) ccall(($(blasfunc(trrfs)), liblapack), Void, - (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, - Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, + (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, + Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{$relty}, Ptr{$elty}, Ptr{$relty}, Ptr{BlasInt}), &uplo, &trans, &diag, &n, &nrhs, A, &max(1,stride(A,2)), B, &max(1,stride(B,2)), X, &max(1,stride(X,2)), @@ -2212,7 +2212,7 @@ for (stev, stebz, stegr, stein, elty) in (Ptr{BlasChar}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), &job, &n, dv, ev, Zmat, &n, work, info) - @lapackerror + @lapackerror dv, Zmat end #* DSTEBZ computes the eigenvalues of a symmetric tridiagonal @@ -2237,10 +2237,10 @@ for (stev, stebz, stegr, stein, elty) in Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), - &range, &order, &n, &vl, - &vu, &il, &iu, &abstol, + &range, &order, &n, &vl, + &vu, &il, &iu, &abstol, dv, ev, m, nsplit, - w, iblock, isplit, work, + w, iblock, isplit, work, iwork, info) @lapackerror w[1:m[1]], iblock[1:m[1]], isplit[1:nsplit[1]] @@ -2334,7 +2334,7 @@ for (stev, stebz, stegr, stein, elty) in Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}), &n, dv, ev, &m, w, iblock, isplit, z, &ldz, work, iwork, ifail, info) - + @lapackerror all(ifail.==0) || error("failed to converge eigenvectors:\n$(nonzeros(ifail))") z @@ -2342,7 +2342,7 @@ for (stev, stebz, stegr, stein, elty) in end end stegr!(jobz::BlasChar, dv::Vector, ev::Vector) = stegr!(jobz, 'A', dv, ev, 0.0, 0.0, 0, 0) - + # Allow user to skip specification of iblock and isplit stein!(dv::Vector, ev::Vector, w_in::Vector)=stein!(dv, ev, w_in, zeros(BlasInt,0), zeros(BlasInt,0)) # Allow user to specify just one eigenvector to get in stein! @@ -2486,7 +2486,7 @@ for (syconv, sysv, sytrf, sytri, sytrs, elty) in A end # SUBROUTINE DSYTRS( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, INFO ) - # + # # .. Scalar Arguments .. # CHARACTER UPLO # INTEGER INFO, LDA, LDB, N, NRHS @@ -2516,7 +2516,7 @@ for (syconv, hesv, hetrf, hetri, hetrs, elty, relty) in (:csyconv_,:chesv_,:chetrf_,:chetri_,:chetrs_,:Complex64, :Float32)) @eval begin # SUBROUTINE ZSYCONV( UPLO, WAY, N, A, LDA, IPIV, WORK, INFO ) - # 22 * + # 22 * # 23 * .. Scalar Arguments .. # 24 * CHARACTER UPLO, WAY # 25 * INTEGER INFO, LDA, N @@ -2665,7 +2665,7 @@ for (syconv, hesv, hetrf, hetri, hetrs, elty, relty) in (Ptr{BlasChar}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), &uplo, &n, &size(B,2), A, &max(1,stride(A,2)), ipiv, B, &max(1,stride(B,2)), info) - @lapackerror + @lapackerror B end end @@ -2852,14 +2852,14 @@ for (syev, syevr, sygvd, elty) in # * .. # * .. Array Arguments .. # INTEGER ISUPPZ( * ), IWORK( * ) - # DOUBLE PRECISION A( LDA, * ), W( * ), WORK( * ), Z( LDZ, * ) + # DOUBLE PRECISION A( LDA, * ), W( * ), WORK( * ), Z( LDZ, * ) function syevr!(jobz::BlasChar, range::BlasChar, uplo::BlasChar, A::StridedMatrix{$elty}, vl::FloatingPoint, vu::FloatingPoint, il::Integer, iu::Integer, abstol::FloatingPoint) chkstride1(A) n = chksquare(A) if range == 'I' 1 <= il <= iu <= n || throw(ArgumentError("illegal choice of eigenvalue indices")) end - if range == 'V' + if range == 'V' vl < vu || throw(ArgumentError("lower boundary must be less than upper boundary")) end lda = max(1,stride(A,2)) @@ -2880,17 +2880,17 @@ for (syev, syevr, sygvd, elty) in info = Array(BlasInt, 1) for i in 1:2 ccall(($(blasfunc(syevr)), liblapack), Void, - (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, - Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, + (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}), - &jobz, &range, &uplo, &n, - A, &lda, &vl, &vu, + &jobz, &range, &uplo, &n, + A, &lda, &vl, &vu, &il, &iu, &abstol, m, w, Z, &ldz, isuppz, - work, &lwork, iwork, &liwork, + work, &lwork, iwork, &liwork, info) @lapackerror if lwork < 0 @@ -2901,8 +2901,8 @@ for (syev, syevr, sygvd, elty) in end end w[1:m[1]], Z[:,1:(jobz == 'V' ? m[1] : 0)] - end - syevr!(jobz::BlasChar, A::StridedMatrix{$elty}) = syevr!(jobz, 'A', 'U', A, 0.0, 0.0, 0, 0, -1.0) + end + syevr!(jobz::BlasChar, A::StridedMatrix{$elty}) = syevr!(jobz, 'A', 'U', A, 0.0, 0.0, 0, 0, -1.0) # Generalized eigenproblem # SUBROUTINE DSYGVD( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK, # $ LWORK, IWORK, LIWORK, INFO ) @@ -2930,9 +2930,9 @@ for (syev, syevr, sygvd, elty) in Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}), - &itype, &jobz, &uplo, &n, - A, &lda, B, &ldb, - w, work, &lwork, iwork, + &itype, &jobz, &uplo, &n, + A, &lda, B, &ldb, + w, work, &lwork, iwork, &liwork, info) if i == 1 lwork = blas_int(work[1]) @@ -2948,11 +2948,11 @@ for (syev, syevr, sygvd, elty) in end end # Hermitian eigensolvers -for (syev, syevr, sygvd, elty, relty) in +for (syev, syevr, sygvd, elty, relty) in ((:zheev_,:zheevr_,:zhegvd_,:Complex128,:Float64), (:cheev_,:cheevr_,:chegvd_,:Complex64,:Float32)) @eval begin -# SUBROUTINE ZHEEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK, INFO ) +# SUBROUTINE ZHEEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK, INFO ) # * .. Scalar Arguments .. # CHARACTER JOBZ, UPLO # INTEGER INFO, LDA, LWORK, N @@ -2993,14 +2993,14 @@ for (syev, syevr, sygvd, elty, relty) in # * .. Array Arguments .. # INTEGER ISUPPZ( * ), IWORK( * ) # DOUBLE PRECISION RWORK( * ), W( * ) -# COMPLEX*16 A( LDA, * ), WORK( * ), Z( LDZ, * ) +# COMPLEX*16 A( LDA, * ), WORK( * ), Z( LDZ, * ) function syevr!(jobz::BlasChar, range::BlasChar, uplo::BlasChar, A::StridedMatrix{$elty}, vl::FloatingPoint, vu::FloatingPoint, il::Integer, iu::Integer, abstol::FloatingPoint) chkstride1(A) n = chksquare(A) if range == 'I' 1 <= il <= iu <= n || throw(ArgumentError("illegal choice of eigenvalue indices")) end - if range == 'V' + if range == 'V' vl < vu || throw(ArgumentError("lower boundary must be less than upper boundary")) end lda = max(1,stride(A,2)) @@ -3023,14 +3023,14 @@ for (syev, syevr, sygvd, elty, relty) in info = Array(BlasInt, 1) for i in 1:2 ccall(($(blasfunc(syevr)), liblapack), Void, - (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, - Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, + (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}), - &jobz, &range, &uplo, &n, - A, &lda, &vl, &vu, + &jobz, &range, &uplo, &n, + A, &lda, &vl, &vu, &il, &iu, &abstol, m, w, Z, &ldz, isuppz, work, &lwork, rwork, &lrwork, @@ -3083,9 +3083,9 @@ for (syev, syevr, sygvd, elty, relty) in Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}), - &itype, &jobz, &uplo, &n, - A, &lda, B, &ldb, - w, work, &lwork, rwork, + &itype, &jobz, &uplo, &n, + A, &lda, B, &ldb, + w, work, &lwork, rwork, &lrwork, iwork, &liwork, info) if i == 1 lwork = blas_int(real(work[1])) @@ -3116,12 +3116,12 @@ for (bdsqr, relty, elty) in #*> zero-shift QR algorithm. function bdsqr!(uplo::BlasChar, d::Vector{$relty}, e_::Vector{$relty}, Vt::StridedMatrix{$elty}, U::StridedMatrix{$elty}, C::StridedMatrix{$elty}) - + # Extract number n = length(d) ncvt, nru, ncc = size(Vt, 2), size(U, 1), size(C, 2) ldvt, ldu, ldc = max(1, stride(Vt,2)), max(1, stride(U, 2)), max(1, stride(C,2)) - + # Do checks @chkuplo length(e_) == n - 1 || throw(DimensionMismatch("off-diagonal has length $(length(e_)) but should have length $(n - 1)")) @@ -3139,13 +3139,13 @@ for (bdsqr, relty, elty) in info = Array(BlasInt,1) ccall(($(blasfunc(bdsqr)), liblapack), Void, - (Ptr{BlasChar}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, - Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, - Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, - Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), - &uplo, &n, &ncvt, &nru, - &ncc, d, e_, Vt, - &ldvt, U, &ldu, C, &ldc, + (Ptr{BlasChar}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, + Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, + Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, + Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), + &uplo, &n, &ncvt, &nru, + &ncc, d, e_, Vt, + &ldvt, U, &ldu, C, &ldc, work, info) @lapackerror @@ -3205,7 +3205,7 @@ for (bdsdc, elty) in q, iq, work, iwork, info) @lapackerror - compq=='N' ? d : (compq=='P' ? (d, q, iq) : (u, d, vt')) + compq=='N' ? d : (compq=='P' ? (d, q, iq) : (u, d, vt')) end end end @@ -3234,7 +3234,7 @@ for (gecon, elty) in iwork = Array(BlasInt, n) info = Array(BlasInt, 1) ccall(($(blasfunc(gecon)), liblapack), Void, - (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, + (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), &normtype, &n, A, &lda, &anorm, rcond, work, iwork, @@ -3268,7 +3268,7 @@ for (gecon, elty, relty) in rwork = Array($relty, 2n) info = Array(BlasInt, 1) ccall(($(blasfunc(gecon)), liblapack), Void, - (Ptr{BlasChar}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, + (Ptr{BlasChar}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{$relty}, Ptr{$elty}, Ptr{$relty}, Ptr{BlasInt}), &normtype, &n, A, &lda, &anorm, rcond, work, rwork, @@ -3303,8 +3303,8 @@ for (gehrd, elty) in (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), - &n, &ilo, &ihi, A, - &max(1,n), tau, work, &lwork, + &n, &ilo, &ihi, A, + &max(1,n), tau, work, &lwork, info) @lapackerror if lwork < 0 @@ -3342,8 +3342,8 @@ for (orghr, elty) in (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}), - &n, &ilo, &ihi, A, - &max(1,n), tau, work, &lwork, + &n, &ilo, &ihi, A, + &max(1,n), tau, work, &lwork, info) @lapackerror if lwork < 0 @@ -3385,9 +3385,9 @@ for (gees, gges, elty) in Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{Void}, Ptr{BlasInt}), - &jobvs, &'N', C_NULL, &n, + &jobvs, &'N', C_NULL, &n, A, &max(1, n), sdim, wr, - wi, vs, &ldvs, work, + wi, vs, &ldvs, work, &lwork, C_NULL, info) @lapackerror if lwork < 0 @@ -3429,11 +3429,11 @@ for (gees, gges, elty) in Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{Void}, Ptr{BlasInt}), - &jobvsl, &jobvsr, &'N', C_NULL, - &n, A, &max(1,n), B, - &max(1,n), &sdim, alphar, alphai, - beta, vsl, &ldvsl, vsr, - &ldvsr, work, &lwork, C_NULL, + &jobvsl, &jobvsr, &'N', C_NULL, + &n, A, &max(1,n), B, + &max(1,n), &sdim, alphar, alphai, + beta, vsl, &ldvsl, vsr, + &ldvsr, work, &lwork, C_NULL, info) if i == 1 lwork = blas_int(real(work[1])) @@ -3473,11 +3473,11 @@ for (gees, gges, elty, relty) in ccall(($(blasfunc(gees)), liblapack), Void, (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{Void}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, - Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, + Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{Void}, Ptr{BlasInt}), - &jobvs, &sort, C_NULL, &n, + &jobvs, &sort, C_NULL, &n, A, &max(1, n), &sdim, w, - vs, &ldvs, work, &lwork, + vs, &ldvs, work, &lwork, rwork, C_NULL, info) @lapackerror if lwork < 0 @@ -3520,11 +3520,11 @@ for (gees, gges, elty, relty) in Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$relty}, Ptr{Void}, Ptr{BlasInt}), - &jobvsl, &jobvsr, &'N', C_NULL, - &n, A, &max(1,n), B, - &max(1,n), &sdim, alpha, beta, - vsl, &ldvsl, vsr, &ldvsr, - work, &lwork, rwork, C_NULL, + &jobvsl, &jobvsr, &'N', C_NULL, + &n, A, &max(1,n), B, + &max(1,n), &sdim, alpha, beta, + vsl, &ldvsl, vsr, &ldvsr, + work, &lwork, rwork, C_NULL, info) if i == 1 lwork = blas_int(real(work[1])) @@ -3696,7 +3696,7 @@ for (fn, elty) in ((:dpftri_, :Float64), ccall(($(blasfunc(fn)), liblapack), Void, (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), - &transr, &uplo, &n, A, + &transr, &uplo, &n, A, info) @assertargsok @assertnonsingular @@ -3763,9 +3763,9 @@ for (fn, elty) in ((:dtftri_, :Float64), n = int(div(sqrt(8length(A)), 2)) info = Array(BlasInt, 1) ccall(($(blasfunc(fn)), liblapack), Void, - (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, + (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}), - &transr, &uplo, &diag, &n, + &transr, &uplo, &diag, &n, A, info) @assertargsok @assertnonsingular @@ -3835,7 +3835,7 @@ for (fn, elty, relty) in ((:dtrsyl_, :Float64, :Float64), scale = Array($relty, 1) info = Array(BlasInt, 1) - + ccall(($(blasfunc(fn)), liblapack), Void, (Ptr{BlasChar}, Ptr{BlasChar}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, @@ -3843,7 +3843,7 @@ for (fn, elty, relty) in ((:dtrsyl_, :Float64, :Float64), &transa, &transb, &isgn, &m, &n, A, &lda, B, &ldb, C, &ldc, scale, info) - @lapackerror + @lapackerror C, scale[1] end end diff --git a/base/linalg/lu.jl b/base/linalg/lu.jl index e2b9fbddc20db..c07806b885efd 100644 --- a/base/linalg/lu.jl +++ b/base/linalg/lu.jl @@ -56,7 +56,7 @@ function generic_lufact!{T}(A::StridedMatrix{T}; pivot = true) for i = k+1:m A[i,j] -= A[i,k]*A[k,j] end - end + end end end LU{T,typeof(A)}(A, ipiv, convert(BlasInt, info)) @@ -75,7 +75,7 @@ end function convert{T}(::Type{LU{T}}, F::LU) M = convert(AbstractMatrix{T}, F.factors) LU{T,typeof(M)}(M, F.ipiv, F.info) -end +end convert{T,S}(::Type{LU{T,S}}, F::LU) = LU{T,S}(convert(S, F.factors), F.ipiv, F.info) convert{T}(::Type{Factorization{T}}, F::LU) = convert(LU{T}, F) @@ -129,7 +129,7 @@ function logdet2{T<:Real,S}(A::LU{T,S}) # return log(abs(det)) and sign(det) n = chksquare(A) dg = diag(A.factors) s = (bool(sum(A.ipiv .!= 1:n) % 2) ? -one(T) : one(T)) * prod(sign(dg)) - sum(log(abs(dg))), s + sum(log(abs(dg))), s end function logdet{T<:Real,S}(A::LU{T,S}) @@ -140,10 +140,10 @@ end function logdet{T<:Complex,S}(A::LU{T,S}) n = chksquare(A) - s = sum(log(diag(A.factors))) + (bool(sum(A.ipiv .!= 1:n) % 2) ? complex(0,pi) : 0) + s = sum(log(diag(A.factors))) + (bool(sum(A.ipiv .!= 1:n) % 2) ? complex(0,pi) : 0) r, a = reim(s) - a = pi-mod(pi-a,2pi) #Take principal branch with argument (-pi,pi] - complex(r,a) + a = pi-mod(pi-a,2pi) #Take principal branch with argument (-pi,pi] + complex(r,a) end inv{T<:BlasFloat,S<:StridedMatrix}(A::LU{T,S}) = @assertnonsingular LAPACK.getri!(copy(A.factors), A.ipiv) A.info diff --git a/base/linalg/sparse.jl b/base/linalg/sparse.jl index 1a0d6d893f1a3..e5010589526c7 100644 --- a/base/linalg/sparse.jl +++ b/base/linalg/sparse.jl @@ -142,7 +142,7 @@ end *{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, B::SparseMatrixCSC{Tv,Ti}) = spmatmul(A,B) -function spmatmul{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, B::SparseMatrixCSC{Tv,Ti}; +function spmatmul{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, B::SparseMatrixCSC{Tv,Ti}; sortindices::Symbol = :sortcols) mA, nA = size(A) mB, nB = size(B) @@ -203,12 +203,12 @@ end function A_ldiv_B!(A::SparseMatrixCSC, b::AbstractVecOrMat) if iseltype(b, Complex); A = complex(A); end - if istril(A) - # TODO: Fix diagonal case. Diagonal(A.nzval) needs to handle + if istril(A) + # TODO: Fix diagonal case. Diagonal(A.nzval) needs to handle # the case where there are zeros on the diagonal and error out. # It also does not work in the complex case. VBS. #if istriu(A); return A_ldiv_B!(Diagonal(A.nzval), b); end - return fwdTriSolve!(A, b) + return fwdTriSolve!(A, b) end if istriu(A); return bwdTriSolve!(A, b); end return A_ldiv_B!(lufact(A),b) @@ -227,11 +227,11 @@ function fwdTriSolve!(A::SparseMatrixCSC, B::AbstractVecOrMat) if nrowB != ncol throw(DimensionMismatch("A is $(ncol)X$(ncol) and B has length $(n)")) end - + aa = A.nzval ja = A.rowval ia = A.colptr - + joff = 0 for k = 1:ncolB for j = 1:(nrowB-1) @@ -265,7 +265,7 @@ function bwdTriSolve!(A::SparseMatrixCSC, B::AbstractVecOrMat) aa = A.nzval ja = A.rowval ia = A.colptr - + joff = 0 for k = 1:ncolB for j = nrowB:-1:2 diff --git a/base/linalg/special.jl b/base/linalg/special.jl index f3e87cbc0c33a..4113e49446d95 100644 --- a/base/linalg/special.jl +++ b/base/linalg/special.jl @@ -62,7 +62,7 @@ convert(::Type{SymTridiagonal}, A::Triangular) = convert(SymTridiagonal, convert function convert(::Type{Tridiagonal}, A::Triangular) fA = full(A) - if fA == diagm(diag(A)) + diagm(diag(fA, 1), 1) + diagm(diag(fA, -1), -1) + if fA == diagm(diag(A)) + diagm(diag(fA, 1), 1) + diagm(diag(fA, -1), -1) return Tridiagonal(diag(fA, -1), diag(A), diag(fA,1)) else throw(ArgumentError("Matrix cannot be represented as Tridiagonal")) @@ -100,7 +100,7 @@ for op in (:+, :-) end end end - + for matrixtype1 in (:Diagonal, :Bidiagonal) #matrixtype1 is the sparser matrix type for matrixtype2 in (:SymTridiagonal,) #matrixtype2 is the denser matrix type @eval begin diff --git a/base/linalg/triangular.jl b/base/linalg/triangular.jl index 15a15ce7bcf4c..e82d2ff666582 100644 --- a/base/linalg/triangular.jl +++ b/base/linalg/triangular.jl @@ -107,17 +107,17 @@ for (uplos, uploc) in ((:(:U), 'U'), (:(:L), 'L')) @eval begin # Vector multiplication A_mul_B!{T<:BlasFloat,S<:StridedMatrix}(A::Triangular{T,S,$uplos,$isunitb}, b::StridedVector{T}) = BLAS.trmv!($uploc, 'N', $isunitc, A.data, b) - + # Matrix multiplication A_mul_B!{T<:BlasFloat,S<:StridedMatrix}(A::Triangular{T,S,$uplos,$isunitb}, B::StridedMatrix{T}) = BLAS.trmm!('L', $uploc, 'N', $isunitc, one(T), A.data, B) A_mul_B!{T<:BlasFloat,S<:StridedMatrix}(A::StridedMatrix{T}, B::Triangular{T,S,$uplos,$isunitb}) = BLAS.trmm!('R', $uploc, 'N', $isunitc, one(T), B.data, A) - + Ac_mul_B!{T<:BlasComplex,S<:StridedMatrix}(A::Triangular{T,S,$uplos,$isunitb}, B::StridedMatrix{T}) = BLAS.trmm!('L', $uploc, 'C', $isunitc, one(T), A.data, B) Ac_mul_B!{T<:BlasReal,S<:StridedMatrix}(A::Triangular{T,S,$uplos,$isunitb}, B::StridedMatrix{T}) = BLAS.trmm!('L', $uploc, 'T', $isunitc, one(T), A.data, B) - + A_mul_Bc!{T<:BlasComplex,S<:StridedMatrix}(A::StridedMatrix{T}, B::Triangular{T,S,$uplos,$isunitb}) = BLAS.trmm!('R', $uploc, 'C', $isunitc, one(T), B.data, A) A_mul_Bc!{T<:BlasReal,S<:StridedMatrix}(A::StridedMatrix{T}, B::Triangular{T,S,$uplos,$isunitb}) = BLAS.trmm!('R', $uploc, 'T', $isunitc, one(T), B.data, A) - + # Left division A_ldiv_B!{T<:BlasFloat,S<:StridedMatrix}(A::Triangular{T,S,$uplos,$isunitb}, B::StridedVecOrMat{T}) = LAPACK.trtrs!($uploc, 'N', $isunitc, A.data, B) Ac_ldiv_B!{T<:BlasReal,S<:StridedMatrix}(A::Triangular{T,S,$uplos,$isunitb}, B::StridedVecOrMat{T}) = LAPACK.trtrs!($uploc, 'T', $isunitc, A.data, B) diff --git a/base/linalg/tridiag.jl b/base/linalg/tridiag.jl index 3650a984e5fac..b1b64cd4a8675 100644 --- a/base/linalg/tridiag.jl +++ b/base/linalg/tridiag.jl @@ -99,7 +99,7 @@ eigvecs{T<:BlasFloat,Eigenvalue<:Real}(m::SymTridiagonal{T}, eigvals::Vector{Eig type ZeroOffsetVector data::Vector end -getindex (a::ZeroOffsetVector, i) = a.data[i+1] +getindex (a::ZeroOffsetVector, i) = a.data[i+1] setindex!(a::ZeroOffsetVector, x, i) = a.data[i+1]=x #Implements the inverse using the recurrence relation between principal minors @@ -134,7 +134,7 @@ function inv_usmani{T}(a::Vector{T}, b::Vector{T}, c::Vector{T}) α[i,j]=(sign)(prod(a[j:i-1]))*θ[j-1]*φ[i+1]/θ[n] end end - α + α end #Implements the determinant using principal minors @@ -203,7 +203,7 @@ end copy!(dest::Tridiagonal, src::Tridiagonal) = Tridiagonal(copy!(dest.dl, src.dl), copy!(dest.d, src.d), copy!(dest.du, src.du), copy!(dest.du2, src.du2)) #Elementary operations -for func in (:copy, :round, :iround, :conj) +for func in (:copy, :round, :iround, :conj) @eval begin ($func)(M::Tridiagonal) = Tridiagonal(map(($func), (M.dl, M.d, M.du, M.du2))...) end @@ -212,7 +212,7 @@ end transpose(M::Tridiagonal) = Tridiagonal(M.du, M.d, M.dl) ctranspose(M::Tridiagonal) = conj(transpose(M)) -diag{T}(M::Tridiagonal{T}, n::Integer=0) = n==0 ? M.d : n==-1 ? M.dl : n==1 ? M.du : abs(n) -pi4o2_h + if x > -pi4o2_h return add22condh(x,0.0,pi4o2_h,pi4o2_l) end end @@ -351,9 +351,9 @@ function mod2pi(x::Float64) # or modtau(x) end else # add pi/2 or 3pi/2 if n & 2 == 2 # add 3pi/2 - return add22condh(y[1],y[2],pi3o2_h,pi3o2_l) + return add22condh(y[1],y[2],pi3o2_h,pi3o2_l) else # add pi/2 - return add22condh(y[1],y[2],pi1o2_h,pi1o2_l) + return add22condh(y[1],y[2],pi1o2_h,pi1o2_l) end end end diff --git a/base/meta.jl b/base/meta.jl index 0947fb34b2b57..20219e681c758 100644 --- a/base/meta.jl +++ b/base/meta.jl @@ -3,8 +3,8 @@ module Meta # convenience functions for metaprogramming # -export quot, - isexpr, +export quot, + isexpr, show_sexpr quot(ex) = Expr(:quote, ex) diff --git a/base/methodshow.jl b/base/methodshow.jl index e591b24a2d4a9..87ae144244046 100644 --- a/base/methodshow.jl +++ b/base/methodshow.jl @@ -83,7 +83,7 @@ function url(m::Method) line <= 0 || ismatch(r"In\[[0-9]+\]", file) && return "" if inbase(M) return "https://github.com/JuliaLang/julia/tree/$(Base.GIT_VERSION_INFO.commit)/base/$file#L$line" - else + else try d = dirname(file) u = Git.readchomp(`config remote.origin.url`, dir=d) @@ -112,7 +112,7 @@ function writemime(io::IO, ::MIME"text/html", m::Method) print(io,"") end print(io, "(") - print_joined(io, [isempty(d[2]) ? d[1] : d[1]*"::"*d[2]*"" + print_joined(io, [isempty(d[2]) ? d[1] : d[1]*"::"*d[2]*"" for d in decls], ",", ",") print(io, ")") if line > 0 @@ -120,7 +120,7 @@ function writemime(io::IO, ::MIME"text/html", m::Method) if isempty(u) print(io, " at ", file, ":", line) else - print(io, """ at """, + print(io, """ at """, file, ":", line, "") end end diff --git a/base/mmap.jl b/base/mmap.jl index 3298c2f32b5da..4b87ea16e6250 100644 --- a/base/mmap.jl +++ b/base/mmap.jl @@ -137,7 +137,7 @@ function mmap_array{T,N}(::Type{T}, dims::NTuple{N,Integer}, s::IO, offset::File # Set the offset to a page boundary offset_page::FileOffset = div(offset, granularity)*granularity szfile = convert(Csize_t, len + offset) - szarray = szfile - convert(Csize_t, offset_page) + szarray = szfile - convert(Csize_t, offset_page) mmaphandle = ccall(:CreateFileMappingW, stdcall, Ptr{Void}, (Ptr{Void}, Ptr{Void}, Cint, Cint, Cint, Ptr{UInt16}), shandle.handle, C_NULL, flprotect, szfile>>32, szfile&typemax(UInt32), C_NULL) if mmaphandle == C_NULL diff --git a/base/mpfr.jl b/base/mpfr.jl index 0bbf107ece02f..eb6a03f410672 100644 --- a/base/mpfr.jl +++ b/base/mpfr.jl @@ -66,7 +66,7 @@ end function BigFloat(x::BigInt) z = BigFloat() - ccall((:mpfr_set_z, :libmpfr), Int32, (Ptr{BigFloat}, Ptr{BigInt}, Int32), &z, &x, ROUNDING_MODE[end]) + ccall((:mpfr_set_z, :libmpfr), Int32, (Ptr{BigFloat}, Ptr{BigInt}, Int32), &z, &x, ROUNDING_MODE[end]) return z end @@ -150,7 +150,7 @@ deserialize(s, ::Type{BigFloat}) = BigFloat(deserialize(s)) # Basic arithmetic without promotion for (fJ, fC) in ((:+,:add), (:*,:mul)) - @eval begin + @eval begin # BigFloat function ($fJ)(x::BigFloat, y::BigFloat) z = BigFloat() @@ -193,7 +193,7 @@ for (fJ, fC) in ((:+,:add), (:*,:mul)) end for (fJ, fC) in ((:-,:sub), (:/,:div)) - @eval begin + @eval begin # BigFloat function ($fJ)(x::BigFloat, y::BigFloat) z = BigFloat() @@ -212,7 +212,7 @@ for (fJ, fC) in ((:-,:sub), (:/,:div)) ccall(($(string(:mpfr_,:ui_,fC)), :libmpfr), Int32, (Ptr{BigFloat}, Culong, Ptr{BigFloat}, Int32), &z, c, &x, ROUNDING_MODE[end]) return z end - + # Signed Integer function ($fJ)(x::BigFloat, c::ClongMax) z = BigFloat() diff --git a/base/multi.jl b/base/multi.jl index abc6ac7a97c0b..628ec44e1f80d 100644 --- a/base/multi.jl +++ b/base/multi.jl @@ -117,7 +117,7 @@ function Worker(host::AbstractString, port::Integer) end w end -function Worker(host::AbstractString, bind_addr::AbstractString, port::Integer, tunnel_user::AbstractString, sshflags) +function Worker(host::AbstractString, bind_addr::AbstractString, port::Integer, tunnel_user::AbstractString, sshflags) w = Worker(host, port, connect("localhost", ssh_tunnel(tunnel_user, host, bind_addr, uint16(port), sshflags))) @@ -224,7 +224,7 @@ function get_bind_addr(w::Union(Worker, LocalProcess)) if w.id != myid() w.bind_addr = remotecall_fetch(w.id, get_bind_addr, w.id) else - error("LPROC.bind_addr not defined") # Should never happend since LPROC.bind_addr + error("LPROC.bind_addr not defined") # Should never happend since LPROC.bind_addr # is defined early on during process init. end end @@ -876,7 +876,7 @@ function create_message_handler_loop(sock::AsyncStream; ntfy_join_complete=nothi # Connect to them if self_is_local && r_is_local # If on localhost, use the loopback address - this addresses - # the special case of system suspend wherein the local ip + # the special case of system suspend wherein the local ip # may be changed upon system awake. w = Worker("127.0.0.1", rport) else @@ -1003,13 +1003,13 @@ function start_cluster_workers(np::Integer, config::Dict, manager::ClusterManage t = @schedule launch(manager, np, config, instance_sets, instances_ntfy) while true - if (length(instance_sets) == 0) + if (length(instance_sets) == 0) istaskdone(t) && break @schedule (sleep(1); notify(instances_ntfy)) wait(instances_ntfy) end - if length(instance_sets) > 0 + if length(instance_sets) > 0 instances = shift!(instance_sets) for inst in instances (io, bind_addr, port, pubhost, wconfig) = read_cb_response(inst...) @@ -1279,12 +1279,12 @@ end # optionally through an SSH tunnel. # the tunnel is only used from the head (process 1); the nodes are assumed # to be mutually reachable without a tunnel, as is often the case in a cluster. -# Default value of kw arg max_parallel is the default value of MaxStartups in sshd_config +# Default value of kw arg max_parallel is the default value of MaxStartups in sshd_config function addprocs_internal(np::Integer; tunnel=false, dir=JULIA_HOME, exename=(ccall(:jl_is_debugbuild,Cint,())==0?"./julia":"./julia-debug"), sshflags::Cmd=``, manager=LocalManager(), exeflags=``, max_parallel=10) - + config = AnyDict(:dir=>dir, :exename=>exename, :exeflags=>`$exeflags --worker`, :tunnel=>tunnel, :sshflags=>sshflags, :max_parallel=>max_parallel) disable_threaded_libs() @@ -1302,7 +1302,7 @@ function addprocs_internal(np::Integer; @schedule (sleep(1); notify(c)) wait(c) end - + if length(resp_arr) > 0 w = shift!(resp_arr) id, rr = add_worker(PGRP, w) @@ -1449,7 +1449,7 @@ function pmap(f, lsts...; err_retry=true, err_stop=false) try result = remotecall_fetch(wpid, f, fvals...) if isa(result, Exception) - ((wpid == myid()) ? rethrow(result) : throw(result)) + ((wpid == myid()) ? rethrow(result) : throw(result)) else results[idx] = result end @@ -1460,7 +1460,7 @@ function pmap(f, lsts...; err_retry=true, err_stop=false) results[idx] = ex end set_task_in_error() - break # remove this worker from accepting any more tasks + break # remove this worker from accepting any more tasks end tasklet = getnext_tasklet() diff --git a/base/osutils.jl b/base/osutils.jl index 9d7a15434c1b1..4f0fc795376d1 100644 --- a/base/osutils.jl +++ b/base/osutils.jl @@ -1,8 +1,8 @@ function is_unix(os::Symbol) - if (os==:Windows) return false; - elseif (os==:Linux) return true; - elseif (os==:FreeBSD) return true; - elseif (os==:Darwin) return true; + if (os==:Windows) return false; + elseif (os==:Linux) return true; + elseif (os==:FreeBSD) return true; + elseif (os==:Darwin) return true; else error("unknown operating system") end end diff --git a/base/path.jl b/base/path.jl index 2cd634cf7e6fd..932f602734a60 100644 --- a/base/path.jl +++ b/base/path.jl @@ -112,8 +112,8 @@ abspath(a::AbstractString, b::AbstractString...) = abspath(joinpath(a,b...)) while true buflength = p buf = zeros(UInt16,buflength) - p = ccall((:GetFullPathNameW, "Kernel32"), stdcall, - UInt32, (Ptr{UInt16}, UInt32, Ptr{UInt16}, Ptr{Void}), + p = ccall((:GetFullPathNameW, "Kernel32"), stdcall, + UInt32, (Ptr{UInt16}, UInt32, Ptr{UInt16}, Ptr{Void}), path, buflength, buf, C_NULL) systemerror(:realpath, p == 0) if (p < buflength) diff --git a/base/poll.jl b/base/poll.jl index 965e864e20c9a..4f4cfb8113408 100644 --- a/base/poll.jl +++ b/base/poll.jl @@ -13,12 +13,12 @@ type FileMonitor this = new(handle,cb,false,Condition()) associate_julia_struct(handle,this) finalizer(this,uvfinalize) - this + this end FileMonitor(file) = FileMonitor(false,file) end -function close(t::FileMonitor) +function close(t::FileMonitor) if t.handle != C_NULL ccall(:jl_close_uv,Void,(Ptr{Void},),t.handle) end @@ -82,11 +82,11 @@ type PollingFileWatcher <: UVPollingWatcher associate_julia_struct(handle,this) finalizer(this,uvfinalize) this - end + end PollingFileWatcher(file) = PollingFileWatcher(false,file) end -@unix_only typealias FDW_FD RawFD +@unix_only typealias FDW_FD RawFD @windows_only typealias FDW_FD WindowsRawSocket @unix_only _get_osfhandle(fd::RawFD) = fd @@ -165,7 +165,7 @@ function _wait(fdw::FDWatcher,readable,writable) events end -# On Unix we can only have one watcher per FD, so we need to keep an explicit +# On Unix we can only have one watcher per FD, so we need to keep an explicit # list of them. On Windows, I think it is techincally possible to have more than one # watcher per FD, but in order to keep compatibility, we do the same on windows as we do # on unix @@ -187,7 +187,7 @@ let fdwatcher_array[fd.fd+1] = FDWatcher(fd) end _wait(fdwatcher_array[fd.fd+1],readable,writable) - end + end end @windows_only begin local fdwatcher_array @@ -204,7 +204,7 @@ let fdwatcher_array[socket] = FDWatcher(socket) end _wait(fdwatcher_array[socket],readable,writable) - end + end end end @@ -325,7 +325,7 @@ function watch_file(cb, s; poll=false) pfw = PollingFileWatcher(cb,s) start_watching(pfw) return pfw - else + else return FileMonitor(cb,s) end end diff --git a/base/printf.jl b/base/printf.jl index dcfe7721ccf0d..86c691ca7aa5d 100644 --- a/base/printf.jl +++ b/base/printf.jl @@ -816,10 +816,10 @@ is_str_expr(ex) = function _printf(macroname, io, fmt, args) isa(fmt, AbstractString) || error("$macroname: format must be a plain static string (no interpolation or prefix)") sym_args, blk = gen(fmt) - + has_splatting = false - for arg in args - if typeof(arg) == Expr && arg.head == :... + for arg in args + if typeof(arg) == Expr && arg.head == :... has_splatting = true break end @@ -827,7 +827,7 @@ function _printf(macroname, io, fmt, args) # # Immediately check for corresponding arguments if there is no splatting - # + # if !has_splatting && length(sym_args) != length(args) error("$macroname: wrong number of arguments ($(length(args))) should be ($(length(sym_args)))") end @@ -874,7 +874,7 @@ end macro sprintf(args...) !isempty(args) || error("@sprintf: called with zero arguments") - isa(args[1], AbstractString) || is_str_expr(args[1]) || + isa(args[1], AbstractString) || is_str_expr(args[1]) || error("@sprintf: first argument must be a format string") blk = _printf("@sprintf", :(IOBuffer()), args[1], args[2:end]) push!(blk.args, :(takebuf_string(out))) diff --git a/base/quadgk.jl b/base/quadgk.jl index a1d89ef61b5a4..17427bec0764c 100644 --- a/base/quadgk.jl +++ b/base/quadgk.jl @@ -65,7 +65,7 @@ function evalrule(f, a,b, x,w,gw, nrm) else # odd: don't count x==0 twice in Gauss rule f0 = f(a + s) Ig += f0 * gw[end] - Ik += f0 * w[end] + + Ik += f0 * w[end] + (f(a + (1+x[end-1])*s) + f(a + (1-x[end-1])*s)) * w[end-1] end Ik *= s @@ -150,14 +150,14 @@ end # Gauss-Kronrod quadrature of f from a to b to c... -function quadgk{T<:FloatingPoint}(f, a::T,b::T,c::T...; +function quadgk{T<:FloatingPoint}(f, a::T,b::T,c::T...; abstol=zero(T), reltol=sqrt(eps(T)), maxevals=10^7, order=7, norm=vecnorm) do_quadgk(f, [a, b, c...], order, T, abstol, reltol, maxevals, norm) end function quadgk{T<:FloatingPoint}(f, a::Complex{T}, - b::Complex{T},c::Complex{T}...; + b::Complex{T},c::Complex{T}...; abstol=zero(T), reltol=sqrt(eps(T)), maxevals=10^7, order=7, norm=vecnorm) do_quadgk(f, [a, b, c...], order, T, abstol, reltol, maxevals, norm) @@ -335,7 +335,7 @@ function kronrod{T<:FloatingPoint}(::Type{T}, n::Integer) b[j] = j / sqrt(4j^2 - o) end gw = T[ 2*eigvec1(b,x[i],n)[1]^2 for i = 2:2:n+1 ] - + return (x, w, gw) end diff --git a/base/random.jl b/base/random.jl index 5bb3e5bdec33a..4b1f84bb6d4dd 100644 --- a/base/random.jl +++ b/base/random.jl @@ -320,11 +320,11 @@ rand(r::MersenneTwister, ::Type{Bool}) = randbool(r) ## randn() - Normally distributed random numbers using Ziggurat algorithm # The Ziggurat Method for generating random variables - Marsaglia and Tsang -# Paper and reference code: http://www.jstatsoft.org/v05/i08/ +# Paper and reference code: http://www.jstatsoft.org/v05/i08/ # randmtzig (covers also exponential variates) ## Tables for normal variates -const ki = +const ki = UInt64[0x0007799ec012f7b3, 0,0x0006045f4c7de363,0x0006d1aa7d5ec0a6, 0x000728fb3f60f778,0x0007592af4e9fbc0,0x000777a5c0bf655d,0x00078ca3857d2256, 0x00079bf6b0ffe58c,0x0007a7a34ab092ae,0x0007b0d2f20dd1cb,0x0007b83d3aa9cb52, @@ -389,7 +389,7 @@ const ki = 0x0007e8d0d3da63d6,0x0007e771023b0fcf,0x0007e5d46c2f08d9,0x0007e3e937669691, 0x0007e195978f1176,0x0007deb2c0e05c1d,0x0007db0362002a1a,0x0007d6202c15143a, 0x0007cf4b8f00a2cc,0x0007c4fd24520efe,0x0007b362fbf81816,0x00078d2d25998e25] -const wi = +const wi = [1.7367254121602630e-15,9.5586603514556339e-17,1.2708704834810623e-16, 1.4909740962495474e-16,1.6658733631586268e-16,1.8136120810119029e-16, 1.9429720153135588e-16,2.0589500628482093e-16,2.1646860576895422e-16, @@ -476,7 +476,7 @@ const wi = 1.3446300925011171e-15,1.3693606835128518e-15,1.3979436672775240e-15, 1.4319989869661328e-15,1.4744848603597596e-15,1.5317872741611144e-15, 1.6227698675312968e-15] -const fi = +const fi = [1.0000000000000000e+00,9.7710170126767082e-01,9.5987909180010600e-01, 9.4519895344229909e-01,9.3206007595922991e-01,9.1999150503934646e-01, 9.0872644005213032e-01,8.9809592189834297e-01,8.8798466075583282e-01, @@ -565,7 +565,7 @@ const fi = 1.2602859304985975e-03] ## Tables for exponential variates -const ke = +const ke = UInt64[0x000e290a13924be4,0 ,0x0009beadebce18c0,0x000c377ac71f9e08, 0x000d4ddb99075857,0x000de893fb8ca23e,0x000e4a8e87c4328e,0x000e8dff16ae1cba, 0x000ebf2deab58c5a,0x000ee49a6e8b9639,0x000f0204efd64ee5,0x000f19bdb8ea3c1c, @@ -631,7 +631,7 @@ UInt64[0x000e290a13924be4,0 ,0x0009beadebce18c0,0x000c377ac71f9e 0x000f930a1a281a05,0x000f889f023d820a,0x000f7b577d2be5f4,0x000f69c650c40a8f, 0x000f51530f0916d9,0x000f2cb0e3c5933e,0x000eeefb15d605d9,0x000e6da6ecf27460] -const we = +const we = [1.9311480126418366e-15,1.4178028487910829e-17,2.3278824993382448e-17, 3.0487830247064320e-17,3.6665697714474878e-17,4.2179302189289733e-17, 4.7222561556862764e-17,5.1911915446217879e-17,5.6323471083955047e-17, @@ -718,7 +718,7 @@ const we = 1.2174462832361815e-15,1.2581958069755114e-15,1.3060984107128082e-15, 1.3642786158057857e-15,1.4384889932178723e-15,1.5412190700064194e-15, 1.7091034077168055e-15] -const fe = +const fe = [1.0000000000000000e+00,9.3814368086217470e-01,9.0046992992574648e-01, 8.7170433238120359e-01,8.4778550062398961e-01,8.2699329664305032e-01, 8.0842165152300838e-01,7.9152763697249562e-01,7.7595685204011555e-01, @@ -811,9 +811,9 @@ ziggurat_nor_inv_r = inv(ziggurat_nor_r) ziggurat_exp_r = 7.6971174701310497140446280481 @inline randi(rng::MersenneTwister=GLOBAL_RNG) = reinterpret(UInt64, rand_close1_open2(rng)) & 0x000fffffffffffff -for (lhs, rhs) in (([], []), +for (lhs, rhs) in (([], []), ([:(rng::MersenneTwister)], [:rng])) - @eval begin + @eval begin function randmtzig_randn($(lhs...)) @inbounds begin while true @@ -836,7 +836,7 @@ for (lhs, rhs) in (([], []), end end end - end + end function randmtzig_exprnd($(lhs...)) @inbounds begin @@ -853,7 +853,7 @@ for (lhs, rhs) in (([], []), end end end - end + end end end diff --git a/base/reduce.jl b/base/reduce.jl index 43d268b1fb722..0a7816d0c3876 100644 --- a/base/reduce.jl +++ b/base/reduce.jl @@ -74,7 +74,7 @@ function mapfoldl_impl(f, op, v0, itr, i) (x, i) = next(itr, i) v = op(v0, f(x)) while !done(itr, i) - (x, i) = next(itr, i) + (x, i) = next(itr, i) v = op(v, f(x)) end return v @@ -153,7 +153,7 @@ end mapreduce(f, op, itr) = mapfoldl(f, op, itr) mapreduce(f, op, v0, itr) = mapfoldl(f, op, v0, itr) -mapreduce_impl(f, op, A::AbstractArray, ifirst::Int, ilast::Int) = +mapreduce_impl(f, op, A::AbstractArray, ifirst::Int, ilast::Int) = mapreduce_seq_impl(f, op, A, ifirst, ilast) # handling empty arrays @@ -226,7 +226,7 @@ sum_pairwise_blocksize(f) = 1024 # This appears to show a benefit from a larger block size sum_pairwise_blocksize(::Abs2Fun) = 4096 -mapreduce_impl(f, op::AddFun, A::AbstractArray, ifirst::Int, ilast::Int) = +mapreduce_impl(f, op::AddFun, A::AbstractArray, ifirst::Int, ilast::Int) = mapreduce_pairwise_impl(f, op, A, ifirst, ilast, sum_pairwise_blocksize(f)) sum(f::Union(Callable,Func{1}), a) = mapreduce(f, AddFun(), a) diff --git a/base/reducedim.jl b/base/reducedim.jl index b15721007113e..b5b09d1be75ad 100644 --- a/base/reducedim.jl +++ b/base/reducedim.jl @@ -7,7 +7,7 @@ reduced_dims(a::AbstractArray, region) = reduced_dims(size(a), region) reduced_dims0(a::AbstractArray, region) = reduced_dims0(size(a), region) reduced_dims{N}(siz::NTuple{N,Int}, d::Int, rd::Int) = (d == 1 ? tuple(rd, siz[d+1:N]...) : d == N ? tuple(siz[1:N-1]..., rd) : - 1 < d < N ? tuple(siz[1:d-1]..., rd, siz[d+1:N]...) : + 1 < d < N ? tuple(siz[1:d-1]..., rd, siz[d+1:N]...) : siz)::typeof(siz) reduced_dims{N}(siz::NTuple{N,Int}, d::Int) = reduced_dims(siz, d, 1) reduced_dims0{N}(siz::NTuple{N,Int}, d::Int) = 1 <= d <= N ? reduced_dims(siz, d, (siz[d] == 0 ? 0 : 1)) : siz @@ -93,7 +93,7 @@ end reducedim_init{T}(f, op::MaxFun, A::AbstractArray{T}, region) = reducedim_initarray0(A, region, typemin(f(zero(T)))) reducedim_init{T}(f, op::MinFun, A::AbstractArray{T}, region) = reducedim_initarray0(A, region, typemax(f(zero(T)))) -reducedim_init{T}(f::Union(AbsFun,Abs2Fun), op::MaxFun, A::AbstractArray{T}, region) = +reducedim_init{T}(f::Union(AbsFun,Abs2Fun), op::MaxFun, A::AbstractArray{T}, region) = reducedim_initarray(A, region, zero(f(zero(T)))) reducedim_init(f, op::AndFun, A::AbstractArray, region) = reducedim_initarray(A, region, true) @@ -112,7 +112,7 @@ for (IT, RT) in ((CommonReduceResult, :(eltype(A))), (SmallSigned, :Int), (Small reducedim_initarray(A, region, real(zero($RT))) reducedim_init(f::Union(AbsFun,Abs2Fun), op::MulFun, A::$T, region) = reducedim_initarray(A, region, real(one($RT))) - end + end end reducedim_init(f::Union(IdFun,AbsFun,Abs2Fun), op::AddFun, A::AbstractArray{Bool}, region) = reducedim_initarray(A, region, 0) @@ -128,7 +128,7 @@ function check_reducdims(R, A) # # It returns an integer value value (useful for choosing implementation) # - If it reduces only along leading dimensions, e.g. sum(A, 1) or sum(A, (1, 2)), - # it returns the length of the leading slice. For the two examples above, + # it returns the length of the leading slice. For the two examples above, # it will be size(A, 1) or size(A, 1) * size(A, 2). # - Otherwise, e.g. sum(A, 2) or sum(A, (1, 3)), it returns 0. # @@ -138,7 +138,7 @@ function check_reducdims(R, A) sRi = size(R, i) sAi = size(A, i) if sRi == 1 - if sAi > 1 + if sAi > 1 if had_nonreduc lsiz = 0 # to reduce along i, but some previous dimensions were non-reducing else @@ -146,7 +146,7 @@ function check_reducdims(R, A) end end else - sRi == sAi || + sRi == sAi || throw(DimensionMismatch("Reduction on array of size $(size(A)) with output of size $(size(R))")) had_nonreduc = true end @@ -177,7 +177,7 @@ end r = op(r, v) end @inbounds (@nref N R j) = r - end + end else # general implementation @nloops N i A d->(j_d = sizeR_d==1 ? 1 : i_d) begin @@ -185,7 +185,7 @@ end @inbounds (@nref N R j) = op((@nref N R j), v) end end - return R + return R end mapreducedim!(f, op, R::AbstractArray, A::AbstractArray) = _mapreducedim!(f, op, R, A) @@ -215,30 +215,30 @@ reducedim(op, A::AbstractArray, region) = mapreducedim(IdFun(), op, A, region) ##### Specific reduction functions ##### -for (fname, Op) in [(:sum, :AddFun), (:prod, :MulFun), - (:maximum, :MaxFun), (:minimum, :MinFun), +for (fname, Op) in [(:sum, :AddFun), (:prod, :MulFun), + (:maximum, :MaxFun), (:minimum, :MinFun), (:all, :AndFun), (:any, :OrFun)] fname! = symbol(string(fname, '!')) - @eval begin - $(fname!)(f::Union(Function,Func{1}), r::AbstractArray, A::AbstractArray; init::Bool=true) = + @eval begin + $(fname!)(f::Union(Function,Func{1}), r::AbstractArray, A::AbstractArray; init::Bool=true) = mapreducedim!(f, $(Op)(), initarray!(r, $(Op)(), init), A) $(fname!)(r::AbstractArray, A::AbstractArray; init::Bool=true) = $(fname!)(IdFun(), r, A; init=init) - $(fname)(f::Union(Function,Func{1}), A::AbstractArray, region) = + $(fname)(f::Union(Function,Func{1}), A::AbstractArray, region) = mapreducedim(f, $(Op)(), A, region) $(fname)(A::AbstractArray, region) = $(fname)(IdFun(), A, region) end end -for (fname, fbase, Fun) in [(:sumabs, :sum, :AbsFun), - (:sumabs2, :sum, :Abs2Fun), - (:maxabs, :maximum, :AbsFun), +for (fname, fbase, Fun) in [(:sumabs, :sum, :AbsFun), + (:sumabs2, :sum, :Abs2Fun), + (:maxabs, :maximum, :AbsFun), (:minabs, :minimum, :AbsFun)] fname! = symbol(string(fname, '!')) fbase! = symbol(string(fbase, '!')) - @eval begin - $(fname!)(r::AbstractArray, A::AbstractArray; init::Bool=true) = + @eval begin + $(fname!)(r::AbstractArray, A::AbstractArray; init::Bool=true) = $(fbase!)($(Fun)(), r, A; init=init) $(fname)(A::AbstractArray, region) = $(fbase)($(Fun)(), A, region) end @@ -292,13 +292,13 @@ end eval(ngenerate(:N, :(typeof((Rval,Rind))), :(_findmin!{T,N}(Rval::AbstractArray, Rind::AbstractArray, A::AbstractArray{T,N})), N->gen_findreduction_body(N, <))) findmin!{R}(rval::AbstractArray{R}, rind::AbstractArray, A::AbstractArray; init::Bool=true) = _findmin!(initarray!(rval, typemax(R), init), rind, A) -findmin{T}(A::AbstractArray{T}, region) = +findmin{T}(A::AbstractArray{T}, region) = isempty(A) ? (similar(A,reduced_dims0(A,region)), zeros(Int,reduced_dims0(A,region))) : _findmin!(reducedim_initarray0(A, region, typemax(T)), zeros(Int,reduced_dims0(A,region)), A) eval(ngenerate(:N, :(typeof((Rval,Rind))), :(_findmax!{T,N}(Rval::AbstractArray, Rind::AbstractArray, A::AbstractArray{T,N})), N->gen_findreduction_body(N, >))) findmax!{R}(rval::AbstractArray{R}, rind::AbstractArray, A::AbstractArray; init::Bool=true) = _findmax!(initarray!(rval, typemin(R), init), rind, A) -findmax{T}(A::AbstractArray{T}, region) = +findmax{T}(A::AbstractArray{T}, region) = isempty(A) ? (similar(A,reduced_dims0(A,region)), zeros(Int,reduced_dims0(A,region))) : _findmax!(reducedim_initarray0(A, region, typemin(T)), zeros(Int,reduced_dims0(A,region)), A) diff --git a/base/regex.jl b/base/regex.jl index 14c74e6c6e111..4d6d4978b7984 100644 --- a/base/regex.jl +++ b/base/regex.jl @@ -256,12 +256,12 @@ filter(r::Regex, d::Dict) = filter!(r,copy(d)) # Don't serialize the pointers function serialize(s, r::Regex) serialize_type(s, typeof(r)) - serialize(s, r.pattern) - serialize(s, r.options) + serialize(s, r.pattern) + serialize(s, r.options) end function deserialize(s, t::Type{Regex}) pattern = deserialize(s) options = deserialize(s) - Regex(pattern, options) + Regex(pattern, options) end diff --git a/base/replutil.jl b/base/replutil.jl index 2bb0cd9b3960e..e78a3e2f91c26 100644 --- a/base/replutil.jl +++ b/base/replutil.jl @@ -31,9 +31,9 @@ function writemime(io::IO, ::MIME"text/plain", v::DataType) # TODO: maybe show constructor info? end -writemime(io::IO, ::MIME"text/plain", t::Associative) = +writemime(io::IO, ::MIME"text/plain", t::Associative) = showdict(io, t, limit=true) -writemime(io::IO, ::MIME"text/plain", t::Union(KeyIterator, ValueIterator)) = +writemime(io::IO, ::MIME"text/plain", t::Union(KeyIterator, ValueIterator)) = showkv(io, t, limit=true) @@ -65,7 +65,7 @@ end function showerror(io::IO, e, bt) try showerror(io, e) - finally + finally show_backtrace(io, bt) end end diff --git a/base/serialize.jl b/base/serialize.jl index aa9f2e8b57cdb..b475de2371b0e 100644 --- a/base/serialize.jl +++ b/base/serialize.jl @@ -21,7 +21,7 @@ let i = 2 Module, UndefRefTag, Task, ASCIIString, UTF8String, UTF16String, UTF32String, Float16, :reserved9, :reserved10, :reserved11, :reserved12, - + (), Bool, Any, :Any, Bottom, Top, Undef, Type, :Array, :TypeVar, :Box, :lambda, :body, :return, :call, symbol("::"), diff --git a/base/sharedarray.jl b/base/sharedarray.jl index 1a0b12a6efbc1..e1e74b12fd950 100644 --- a/base/sharedarray.jl +++ b/base/sharedarray.jl @@ -33,10 +33,10 @@ function SharedArray(T::Type, dims::NTuple; init=false, pids=Int[]) pids = procs(myid()) onlocalhost = true else - if !check_same_host(pids) + if !check_same_host(pids) error("SharedArray requires all requested processes to be on the same machine.") end - + onlocalhost = myid() in procs(pids[1]) end @@ -339,7 +339,7 @@ function shm_mmap_array(T, dims, shm_seg_name, mode) if prod(dims) == 0 return Array(T, dims) end - + try fd_mem = shm_open(shm_seg_name, mode, S_IRUSR | S_IWUSR) systemerror("shm_open() failed for " * shm_seg_name, fd_mem <= 0) diff --git a/base/show.jl b/base/show.jl index f923ec6f4486d..9400e2dbc42f1 100644 --- a/base/show.jl +++ b/base/show.jl @@ -10,18 +10,18 @@ function show(io::IO, x::ANY) recorded = false oid = object_id(x) shown_set = get(task_local_storage(), :SHOWNSET, nothing) - if shown_set == nothing + if shown_set == nothing shown_set = Set() - task_local_storage(:SHOWNSET, shown_set) + task_local_storage(:SHOWNSET, shown_set) end - + try if oid in shown_set print(io, "#= circular reference =#") else push!(shown_set, oid) recorded = true - + n = length(t.names) for i=1:n f = t.names[i] @@ -37,7 +37,7 @@ function show(io::IO, x::ANY) end catch e rethrow(e) - + finally if recorded delete!(shown_set, oid) end end @@ -206,7 +206,7 @@ show(io::IO, s::Symbol) = show_unquoted(io, QuoteNode(s)) # print(io, ex) defers to show_unquoted(io, ex) # show(io, ex) defers to show_unquoted(io, QuoteNode(ex)) # show_unquoted(io, ex) does the heavy lifting -# +# # AST printing should follow two rules: # 1. parse(string(ex)) == ex # 2. eval(parse(repr(ex))) == ex @@ -442,7 +442,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int) # (:calldecl is a "fake" expr node created when we find a :function expr) elseif head == :calldecl && nargs >= 1 show_call(io, head, args[1], args[2:end], indent) - + # function call elseif haskey(expr_calls, head) && nargs >= 1 # :call/:ref/:curly func = args[1] @@ -746,7 +746,7 @@ function dumptype(io::IO, x, n::Int, indent) # based on Jameson Nash's examples/typetree.jl println(io, x) if n == 0 # too deeply nested - return + return end typargs(t) = split(string(t), "{")[1] # todo: include current module? @@ -771,7 +771,7 @@ function dumptype(io::IO, x, n::Int, indent) # type aliases if string(s) != string(t.name) println(io, indent, " ", s, " = ", t.name) - elseif t != Any + elseif t != Any print(io, indent, " ") dump(io, t, n - 1, string(indent, " ")) end diff --git a/base/socket.jl b/base/socket.jl index 67139fc35fdaf..78d73aaf0060e 100644 --- a/base/socket.jl +++ b/base/socket.jl @@ -19,7 +19,7 @@ end function IPv4(host::Integer) if host < 0 error("IP address must not be negative") - elseif typemax(typeof(host)) > typemax(UInt32) && host > typemax(UInt32) + elseif typemax(typeof(host)) > typemax(UInt32) && host > typemax(UInt32) error("IPv4 address must fit within 32 bits") else return IPv4(uint32(host)) @@ -60,7 +60,7 @@ function IPv6(host::Integer) error("IP address must not be negative") # We allow passing bigger integer types, but need to be careful to avoid overflow # Let's hope promotion rules are sensible - elseif typemax(typeof(host)) > typemax(UInt128) && host > typemax(UInt128) + elseif typemax(typeof(host)) > typemax(UInt128) && host > typemax(UInt128) error("IPv6 address must fit within 128 bits") else return IPv6(uint128(host)) @@ -71,7 +71,7 @@ end print_ipv6_field(io,field::UInt16) = print(io,hex(field)) print_ipv6_field(io,ip,i) = print_ipv6_field(io,ipv6_field(ip,i)) -function ipv6_field(ip::IPv6,i) +function ipv6_field(ip::IPv6,i) if i < 0 || i > 7 throw(BoundsError()) end @@ -132,7 +132,7 @@ function parseipv4(str) fields = split(str,'.') i = 1 ret = 0 - for f in fields + for f in fields if length(f) == 0 error("empty field in IPv4 address") end @@ -142,7 +142,7 @@ function parseipv4(str) error("IPv4 field too large") end r = parseint(f[3:end],16) - else + else if length(f) > 9 # 1+8 - prevent parseint from overflowing on 32bit error("IPv4 field too large") end @@ -173,11 +173,11 @@ function parseipv6fields(fields,num_fields) end cf = 7 ret = uint128(0) - for f in fields + for f in fields if f == "" # ::abc:... and ..:abc:: if cf != 7 && cf != 0 - cf -= num_fields-length(fields) + cf -= num_fields-length(fields) end cf -= 1 continue @@ -203,7 +203,7 @@ function parseipv6(str) end end -# +# # This support IPv4 addresses in the common dot (IPv4) or colon (IPv6) # separated formats. Most other common formats use a standard integer encoding # of the appropriate size and should use the appropriate constructor @@ -267,7 +267,7 @@ function TCPSocket() finalizer(this,uvfinalize) err = ccall(:uv_tcp_init,Cint,(Ptr{Void},Ptr{Void}), eventloop(),this.handle) - if err != 0 + if err != 0 c_free(this.handle) this.handle = C_NULL error(UVError("failed to create tcp socket",err)) @@ -297,7 +297,7 @@ function TCPServer() finalizer(this,uvfinalize) err = ccall(:uv_tcp_init,Cint,(Ptr{Void},Ptr{Void}), eventloop(),this.handle) - if err != 0 + if err != 0 c_free(this.handle) this.handle = C_NULL error(UVError("failed to create tcp server",err)) @@ -322,11 +322,11 @@ show(io::IO,sock::TCPServer) = print(io,"TCPServer(",uv_status_string(sock),")") ## VARIOUS METHODS TO BE MOVED TO BETTER LOCATION -_jl_connect_raw(sock::TCPSocket,sockaddr::Ptr{Void}) = +_jl_connect_raw(sock::TCPSocket,sockaddr::Ptr{Void}) = ccall(:jl_connect_raw,Int32,(Ptr{Void},Ptr{Void}),sock.handle,sockaddr) -_jl_sockaddr_from_addrinfo(addrinfo::Ptr{Void}) = +_jl_sockaddr_from_addrinfo(addrinfo::Ptr{Void}) = ccall(:jl_sockaddr_from_addrinfo,Ptr{Void},(Ptr{Void},),addrinfo) -_jl_sockaddr_set_port(ptr::Ptr{Void},port::UInt16) = +_jl_sockaddr_set_port(ptr::Ptr{Void},port::UInt16) = ccall(:jl_sockaddr_set_port,Void,(Ptr{Void},UInt16),ptr,port) accept(server::TCPServer) = accept(server, TCPSocket()) @@ -342,7 +342,7 @@ _bind(sock::TCPServer, host::IPv4, port::UInt16) = ccall(:jl_tcp_bind, Int32, (P _bind(sock::TCPServer, host::IPv6, port::UInt16) = ccall(:jl_tcp_bind6, Int32, (Ptr{Void}, UInt16, Ptr{UInt128}, Cuint), sock.handle, hton(port), &hton(host.host), 0) -# UDP +# UDP type UDPSocket <: Socket handle::Ptr{Void} @@ -352,7 +352,7 @@ type UDPSocket <: Socket closenotify::Condition UDPSocket(handle::Ptr) = new( - handle, + handle, StatusUninit, Condition(), Condition(), @@ -365,7 +365,7 @@ function UDPSocket() err = ccall(:uv_udp_init,Cint,(Ptr{Void},Ptr{Void}), eventloop(),this.handle) finalizer(this, uvfinalize) - if err != 0 + if err != 0 c_free(this.handle) this.handle = C_NULL error(UVError("failed to create udp socket",err)) @@ -394,7 +394,7 @@ end const UV_UDP_IPV6ONLY = 1 # Indicates message was truncated because read buffer was too small. The -# remainder was discarded by the OS. +# remainder was discarded by the OS. const UV_UDP_PARTIAL = 2 function bind(sock::Union(TCPServer,UDPSocket), host::IPv4, port::Integer) @@ -433,7 +433,7 @@ end function setopt(sock::UDPSocket; multicast_loop = nothing, multicast_ttl=nothing, enable_broadcast=nothing, ttl=nothing) - if sock.status == StatusUninit + if sock.status == StatusUninit error("Cannot set options on unitialized socket") end if multicast_loop !== nothing @@ -463,7 +463,7 @@ _recv_stop(sock::UDPSocket) = uv_error("recv_stop",ccall(:uv_udp_recv_stop,Cint, function recv(sock::UDPSocket) # If the socket has not been bound, it will be bound implicitly to ::0 and a random port - if sock.status != StatusInit && sock.status != StatusOpen + if sock.status != StatusInit && sock.status != StatusOpen error("Invalid socket state") end _recv_start(sock) @@ -480,17 +480,17 @@ function _uv_hook_recv(sock::UDPSocket, nread::Int, buf_addr::Ptr{Void}, buf_siz notify(sock.recvnotify,buf[1:nread]) end -function _send(sock::UDPSocket,ipaddr::IPv4,port::UInt16,buf) +function _send(sock::UDPSocket,ipaddr::IPv4,port::UInt16,buf) ccall(:jl_udp_send,Cint,(Ptr{Void},UInt16,UInt32,Ptr{UInt8},Csize_t),sock.handle,hton(port),hton(ipaddr.host),buf,sizeof(buf)) end -function _send(sock::UDPSocket,ipaddr::IPv6,port::UInt16,buf) +function _send(sock::UDPSocket,ipaddr::IPv6,port::UInt16,buf) ccall(:jl_udp_send6,Cint,(Ptr{Void},UInt16,Ptr{UInt128},Ptr{UInt8},Csize_t),sock.handle,hton(port),&hton(ipaddr.host),buf,sizeof(buf)) end function send(sock::UDPSocket,ipaddr,port,msg) # If the socket has not been bound, it will be bound implicitly to ::0 and a random port - if sock.status != StatusInit && sock.status != StatusOpen + if sock.status != StatusInit && sock.status != StatusOpen error("Invalid socket state") end uv_error("send",_send(sock,ipaddr,uint16(port),msg)) @@ -617,7 +617,7 @@ default_connectcb(sock,status) = nothing function connect!(sock::TCPSocket, host::AbstractString, port::Integer) @assert sock.status == StatusInit - ipaddr = getaddrinfo(host) + ipaddr = getaddrinfo(host) sock.status = StatusInit connect!(sock,ipaddr,port) sock.status = StatusConnecting diff --git a/base/sparse.jl b/base/sparse.jl index c2f153e72844f..87c381af430aa 100644 --- a/base/sparse.jl +++ b/base/sparse.jl @@ -5,11 +5,11 @@ module SparseMatrix importall Base import Base.NonTupleType, Base.float, Base.Order, Base.Sort.Forward -export SparseMatrixCSC, - blkdiag, dense, diag, diagm, droptol!, dropzeros!, etree, full, +export SparseMatrixCSC, + blkdiag, dense, diag, diagm, droptol!, dropzeros!, etree, full, getindex, ishermitian, issparse, issym, istril, istriu, nnz, - setindex!, sparse, sparsevec, spdiagm, speye, spones, - sprand, sprandbool, sprandn, spzeros, symperm, trace, tril, tril!, + setindex!, sparse, sparsevec, spdiagm, speye, spones, + sprand, sprandbool, sprandn, spzeros, symperm, trace, tril, tril!, triu, triu!, nonzeros, rowvals, nzrange include("sparse/sparsematrix.jl") diff --git a/base/sparse/csparse.jl b/base/sparse/csparse.jl index a22a3f9b98364..16cc05526d9cc 100644 --- a/base/sparse/csparse.jl +++ b/base/sparse/csparse.jl @@ -12,7 +12,7 @@ # Based on Direct Methods for Sparse Linear Systems, T. A. Davis, SIAM, Philadelphia, Sept. 2006. # Section 2.4: Triplet form # http://www.cise.ufl.edu/research/sparse/CSparse/ -function sparse{Tv,Ti<:Integer}(I::AbstractVector{Ti}, J::AbstractVector{Ti}, +function sparse{Tv,Ti<:Integer}(I::AbstractVector{Ti}, J::AbstractVector{Ti}, V::AbstractVector{Tv}, nrow::Integer, ncol::Integer, combine::Function) @@ -94,7 +94,7 @@ function sparse{Tv,Ti<:Integer}(I::AbstractVector{Ti}, J::AbstractVector{Ti}, @simd for i=2:(ncol+1); @inbounds Wj[i] = 0; end @inbounds for j = 1:nrow p1 = Rp[j] - p2 = p1 + Rnz[j] - 1 + p2 = p1 + Rnz[j] - 1 for p = p1:p2 Wj[Ri[p]+1] += 1 end @@ -196,7 +196,7 @@ function ctranspose!{Tv,Ti}(S::SparseMatrixCSC{Tv,Ti}, T::SparseMatrixCSC{Tv,Ti} return T end -function ctranspose{Tv,Ti}(S::SparseMatrixCSC{Tv,Ti}) +function ctranspose{Tv,Ti}(S::SparseMatrixCSC{Tv,Ti}) (nT, mT) = size(S) nnzS = nnz(S) colptr_T = Array(Ti, nT+1) @@ -281,7 +281,7 @@ end # based on cs_permute p. 21, "Direct Methods for Sparse Linear Systems" function csc_permute{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, pinv::Vector{Ti}, q::Vector{Ti}) m,n = size(A); Ap = A.colptr; Ai = A.rowval; Ax = A.nzval - if length(pinv) != m || length(q) != n + if length(pinv) != m || length(q) != n error("dimension mismatch, size(A) = $(size(A)), length(pinv) = $(length(pinv)) and length(q) = $(length(q))") end if !isperm(pinv) || !isperm(q) error("both pinv and q must be permutations") end diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index 0eb90a8e2399f..ae8647073e7c1 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -369,10 +369,10 @@ function sprand{T}(m::Integer, n::Integer, density::FloatingPoint, # density of nonzero columns: L = log1p(-density) - coldensity = -expm1(m*L) # = 1 - (1-density)^m + coldensity = -expm1(m*L) # = 1 - (1-density)^m colsparsity = exp(m*L) # = 1 - coldensity L = 1/L - + rows = Array(Int, 0) for j in randsubseq(1:n, coldensity) # To get the right statistics, we *must* have a nonempty column j @@ -511,7 +511,7 @@ for op in (:cos, :cosh, :acos, :sec, :csc, :cot, :acot, :sech, end return B end - + end end @@ -1324,7 +1324,7 @@ function spset!{Tv,Ti<:Integer}(A::SparseMatrixCSC{Tv}, x::Tv, I::AbstractVector colptrA[n+1] = rowidx deleteat!(rowvalA, rowidx:nnzA) deleteat!(nzvalA, rowidx:nnzA) - + A.colptr = colptrA A.rowval = rowvalA A.nzval = nzvalA @@ -1381,7 +1381,7 @@ function spdelete!{Tv,Ti<:Integer}(A::SparseMatrixCSC{Tv}, I::AbstractVector{Ti} colptrA[n+1] = rowidx deleteat!(rowvalA, rowidx:nnzA) deleteat!(nzvalA, rowidx:nnzA) - + A.colptr = colptrA A.rowval = rowvalA A.nzval = nzvalA @@ -1432,7 +1432,7 @@ function setindex!{Tv,Ti,T<:Integer}(A::SparseMatrixCSC{Tv,Ti}, B::SparseMatrixC colptrS = Array(Ti, n+1) rowvalS = Array(Ti, nnzS) nzvalS = Array(Tv, nnzS) - + colptrS[1] = 1 colB = 1 asgn_col = J[colB] @@ -1447,7 +1447,7 @@ function setindex!{Tv,Ti,T<:Integer}(A::SparseMatrixCSC{Tv,Ti}, B::SparseMatrixC # Copy column of A if it is not being assigned into if colB > nJ || col != J[colB] colptrS[col+1] = colptrS[col] + (colptrA[col+1]-colptrA[col]) - + for k = colptrA[col]:colptrA[col+1]-1 rowvalS[ptrS] = rowvalA[k] nzvalS[ptrS] = nzvalA[k] @@ -1740,7 +1740,7 @@ end function vcat(X::SparseMatrixCSC...) num = length(X) - mX = [ size(x, 1) for x in X ] + mX = [ size(x, 1) for x in X ] nX = [ size(x, 2) for x in X ] n = nX[1] for i = 2 : num @@ -1911,7 +1911,7 @@ function istril{Tv}(A::SparseMatrixCSC{Tv}) return true end -# Create a sparse diagonal matrix by specifying multiple diagonals +# Create a sparse diagonal matrix by specifying multiple diagonals # packed into a tuple, alongside their diagonal offsets and matrix shape function spdiagm_internal(B, d) @@ -2072,7 +2072,7 @@ function sortSparseMatrixCSC!{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}; sortindices::Sym for i = 1:n @inbounds col_start = colptr[i] @inbounds col_end = (colptr[i+1] - 1) - + numrows = col_end - col_start + 1 if numrows <= 1 continue diff --git a/base/special/bessel.jl b/base/special/bessel.jl index b0db31aac8917..c32b8c9b34de1 100644 --- a/base/special/bessel.jl +++ b/base/special/bessel.jl @@ -20,7 +20,7 @@ for jy in ("j","y"), nu in (0,1) end end - + type AmosException <: Exception info::Int32 end @@ -37,11 +37,11 @@ let &id, &kode, pointer(ai,1), pointer(ai,2), pointer(ae,1), pointer(ae,2)) - if ae[2] == 0 || ae[2] == 3 + if ae[2] == 0 || ae[2] == 3 return complex(ai[1],ai[2]) else throw(AmosException(ae[2])) - end + end end function _biry(z::Complex128, id::Int32, kode::Int32) ccall((:zbiry_,openspecfun), Void, @@ -52,7 +52,7 @@ let pointer(ai,1), pointer(ai,2), pointer(ae,1)) if ae[1] == 0 || ae[1] == 3 # ignore underflow - return complex(ai[1],ai[2]) + return complex(ai[1],ai[2]) else throw(AmosException(ae[2])) end @@ -120,8 +120,8 @@ function _besselh(nu::Float64, k::Int32, z::Complex128, kode::Int32) &real(z), &imag(z), &nu, &kode, &k, &1, pointer(cy,1), pointer(cy,2), pointer(ae,1), pointer(ae,2)) - if ae[2] == 0 || ae[2] == 3 - return complex(cy[1],cy[2]) + if ae[2] == 0 || ae[2] == 3 + return complex(cy[1],cy[2]) else throw(AmosException(ae[2])) end @@ -134,8 +134,8 @@ function _besseli(nu::Float64, z::Complex128, kode::Int32) &real(z), &imag(z), &nu, &kode, &1, pointer(cy,1), pointer(cy,2), pointer(ae,1), pointer(ae,2)) - if ae[2] == 0 || ae[2] == 3 - return complex(cy[1],cy[2]) + if ae[2] == 0 || ae[2] == 3 + return complex(cy[1],cy[2]) else throw(AmosException(ae[2])) end @@ -148,8 +148,8 @@ function _besselj(nu::Float64, z::Complex128, kode::Int32) &real(z), &imag(z), &nu, &kode, &1, pointer(cy,1), pointer(cy,2), pointer(ae,1), pointer(ae,2)) - if ae[2] == 0 || ae[2] == 3 - return complex(cy[1],cy[2]) + if ae[2] == 0 || ae[2] == 3 + return complex(cy[1],cy[2]) else throw(AmosException(ae[2])) end @@ -162,8 +162,8 @@ function _besselk(nu::Float64, z::Complex128, kode::Int32) &real(z), &imag(z), &nu, &kode, &1, pointer(cy,1), pointer(cy,2), pointer(ae,1), pointer(ae,2)) - if ae[2] == 0 || ae[2] == 3 - return complex(cy[1],cy[2]) + if ae[2] == 0 || ae[2] == 3 + return complex(cy[1],cy[2]) else throw(AmosException(ae[2])) end @@ -178,8 +178,8 @@ function _bessely(nu::Float64, z::Complex128, kode::Int32) pointer(cy,1), pointer(cy,2), pointer(ae,1), pointer(wrk,1), pointer(wrk,2), pointer(ae,2)) - if ae[2] == 0 || ae[2] == 3 - return complex(cy[1],cy[2]) + if ae[2] == 0 || ae[2] == 3 + return complex(cy[1],cy[2]) else throw(AmosException(ae[2])) end @@ -255,7 +255,7 @@ end function besselyx(nu::Float64, z::Complex128) if nu < 0 - return _bessely(-nu,z,int32(2))*cospi(nu) - _besselj(-nu,z,int32(2))*sinpi(nu) + return _bessely(-nu,z,int32(2))*cospi(nu) - _besselj(-nu,z,int32(2))*sinpi(nu) else return _bessely(nu,z,int32(2)) end diff --git a/base/special/erf.jl b/base/special/erf.jl index 5b2ab18ab26c3..72ef04ebd6894 100644 --- a/base/special/erf.jl +++ b/base/special/erf.jl @@ -19,12 +19,12 @@ for f in (:erfcx, :erfi, :Dawson) end end -# Compute the inverse of the error function: erf(erfinv(x)) == x, +# Compute the inverse of the error function: erf(erfinv(x)) == x, # using the rational approximants tabulated in: -# J. M. Blair, C. A. Edwards, and J. H. Johnson, "Rational Chebyshev +# J. M. Blair, C. A. Edwards, and J. H. Johnson, "Rational Chebyshev # approximations for the inverse of the error function," Math. Comp. 30, # pp. 827--830 (1976). -# http://dx.doi.org/10.1090/S0025-5718-1976-0421040-7 +# http://dx.doi.org/10.1090/S0025-5718-1976-0421040-7 # http://www.jstor.org/stable/2005402 function erfinv(x::Float64) a = abs(x) @@ -37,7 +37,7 @@ function erfinv(x::Float64) throw(DomainError()) elseif a <= 0.75 # Table 17 in Blair et al. t = x*x - 0.5625 - return x * @horner(t, 0.16030_49558_44066_229311e2, + return x * @horner(t, 0.16030_49558_44066_229311e2, -0.90784_95926_29603_26650e2, 0.18644_91486_16209_87391e3, -0.16900_14273_46423_82420e3, @@ -79,7 +79,7 @@ function erfinv(x::Float64) 0.85475_61182_21678_27825_185e1, 0.68738_08807_35438_39802_913e1, 0.36270_02483_09587_08930_02e1, - 0.88606_27392_96515_46814_9) / + 0.88606_27392_96515_46814_9) / (copysign(t, x) * @horner(t, 0.10501_26668_70303_37690e-3, 0.10532_86230_09333_27531_11e-1, @@ -140,7 +140,7 @@ end erfinv(x::Integer) = erfinv(float(x)) @vectorize_1arg Real erfinv -# Inverse complementary error function: use Blair tables for y = 1-x, +# Inverse complementary error function: use Blair tables for y = 1-x, # exploiting the greater accuracy of y (vs. x) when y is small. function erfcinv(y::Float64) if y > 0.0625 @@ -160,7 +160,7 @@ function erfcinv(y::Float64) 0.85475_61182_21678_27825_185e1, 0.68738_08807_35438_39802_913e1, 0.36270_02483_09587_08930_02e1, - 0.88606_27392_96515_46814_9) / + 0.88606_27392_96515_46814_9) / (t * @horner(t, 0.10501_26668_70303_37690e-3, 0.10532_86230_09333_27531_11e-1, diff --git a/base/special/gamma.jl b/base/special/gamma.jl index 93994662d0cc7..09f40f62f06a8 100644 --- a/base/special/gamma.jl +++ b/base/special/gamma.jl @@ -27,7 +27,7 @@ const clg_coeff = [76.18009172947146, function clgamma_lanczos(z) const sqrt2pi = 2.5066282746310005 - + y = x = z temp = x + 5.5 zz = log(temp) @@ -224,7 +224,7 @@ function inv_oftype(x::Complex, y::Real) end inv_oftype(x::Real, y::Real) = oftype(x, inv(y)) -# Hurwitz zeta function, which is related to polygamma +# Hurwitz zeta function, which is related to polygamma # (at least for integer m > 0 and real(z) > 0) by: # polygamma(m, z) = (-1)^(m+1) * gamma(m+1) * zeta(m+1, z). # Our algorithm for the polygamma is just the m-th derivative @@ -428,7 +428,7 @@ function zeta(s::Union(Float64,Complex{Float64})) -1.0031782279542924256050500133649802190, -1.00078519447704240796017680222772921424, -0.9998792995005711649578008136558752359121) - end + end return zeta(1 - s) * gamma(1 - s) * sinpi(s*0.5) * (2π)^s / π end @@ -442,14 +442,14 @@ function zeta(s::Union(Float64,Complex{Float64})) for ν = 2:n ζₒ= ζ ζ += inv(ν)^s - ζ == ζₒ && break # prevent long loop for large m + ζ == ζₒ && break # prevent long loop for large m end z = 1 + n t = inv(z) w = t^m ζ += w * (inv(m) + 0.5*t) - t *= t # 1/z^2 + t *= t # 1/z^2 ζ += w*t * @pg_horner(t,m,0.08333333333333333,-0.008333333333333333,0.003968253968253968,-0.004166666666666667,0.007575757575757576,-0.021092796092796094,0.08333333333333333,-0.4432598039215686,3.0539543302701198) return ζ diff --git a/base/special/trig.jl b/base/special/trig.jl index 5486f412af6b9..b23e41b3a5dc7 100644 --- a/base/special/trig.jl +++ b/base/special/trig.jl @@ -53,7 +53,7 @@ function sin_kernel(x::DoubleFloat32) S2 = 0.008333329385889463 S3 = -0.00019839334836096632 S4 = 2.718311493989822e-6 - + z = x.hi*x.hi w = z*z r = S3+z*S4 @@ -86,7 +86,7 @@ function mulpi_ext(x::Float64) u = 134217729.0*x # 0x1p27 + 1 x_hi = u-(u-x) x_lo = x-x_hi - + y_hi = m*x y_lo = x_hi * m_lo + (x_lo* m_hi + ((x_hi*m_hi-y_hi) + x_lo*m_lo)) @@ -223,7 +223,7 @@ function deg2rad_ext(x::Float64) u = 134217729.0*x # 0x1p27 + 1 x_hi = u-(u-x) x_lo = x-x_hi - + y_hi = m*x y_lo = x_hi * m_lo + (x_lo* m_hi + ((x_hi*m_hi-y_hi) + x_lo*m_lo)) @@ -243,7 +243,7 @@ function sind(x::Real) arx = abs(rx) if rx == zero(rx) - return rx + return rx elseif arx < oftype(rx,45) return sin_kernel(deg2rad_ext(rx)) elseif arx <= oftype(rx,135) diff --git a/base/statistics.jl b/base/statistics.jl index 38a3c13598ad0..2037a4af850c3 100644 --- a/base/statistics.jl +++ b/base/statistics.jl @@ -32,7 +32,7 @@ momenttype{T}(::Type{T}) = typeof((zero(T) + zero(T)) / 2) momenttype(::Type{Float32}) = Float32 momenttype{T<:Union(Float64,Int32,Int64,UInt32,UInt64)}(::Type{T}) = Float64 -mean{T}(A::AbstractArray{T}, region) = +mean{T}(A::AbstractArray{T}, region) = mean!(Array(momenttype(T), reduced_dims(size(A), region)), A) @@ -46,8 +46,8 @@ function var(iterable; corrected::Bool=true, mean=nothing) count = 1 value, state = next(iterable, state) if mean == nothing - # Use Welford algorithm as seen in (among other places) - # Knuth's TAOCP, Vol 2, page 232, 3rd edition. + # Use Welford algorithm as seen in (among other places) + # Knuth's TAOCP, Vol 2, page 232, 3rd edition. M = value / 1 S = zero(M) while !done(iterable, state) @@ -61,7 +61,7 @@ function var(iterable; corrected::Bool=true, mean=nothing) elseif isa(mean, Number) # mean provided # Cannot use a compensated version, e.g. the one from # "Updating Formulae and a Pairwise Algorithm for Computing Sample Variances." - # by Chan, Golub, and LeVeque, Technical Report STAN-CS-79-773, + # by Chan, Golub, and LeVeque, Technical Report STAN-CS-79-773, # Department of Computer Science, Stanford University, # because user can provide mean value that is different to mean(iterable) sum2 = (value - mean::Number)^2 @@ -92,7 +92,7 @@ function varzm!{S}(R::AbstractArray{S}, A::AbstractArray; corrected::Bool=true) return R end -varzm{T}(A::AbstractArray{T}, region; corrected::Bool=true) = +varzm{T}(A::AbstractArray{T}, region; corrected::Bool=true) = varzm!(Array(momenttype(T), reduced_dims(A, region)), A; corrected=corrected) immutable CentralizedAbs2Fun{T<:Number} <: Func{1} @@ -122,12 +122,12 @@ centralize_sumabs2(A::AbstractArray, m::Number, ifirst::Int, ilast::Int) = # keep the accumulator as a local variable when reducing along the first dimension @nloops N i d->(d>1? (1:size(A,d)) : (1:1)) d->(j_d = sizeR_d==1 ? 1 : i_d) begin @inbounds r = (@nref N R j) - @inbounds m = (@nref N means j) + @inbounds m = (@nref N means j) for i_1 = 1:sizA1 @inbounds r += abs2((@nref N A i) - m) end @inbounds (@nref N R j) = r - end + end else # general implementation @nloops N i A d->(j_d = sizeR_d==1 ? 1 : i_d) begin @@ -154,7 +154,7 @@ function varm!{S}(R::AbstractArray{S}, A::AbstractArray, m::AbstractArray; corre return R end -varm{T}(A::AbstractArray{T}, m::AbstractArray, region; corrected::Bool=true) = +varm{T}(A::AbstractArray{T}, m::AbstractArray, region; corrected::Bool=true) = varm!(Array(momenttype(T), reduced_dims(size(A), region)), A, m; corrected=corrected) @@ -191,20 +191,20 @@ end ##### standard deviation ##### -function sqrt!(A::AbstractArray) +function sqrt!(A::AbstractArray) for i = 1:length(A) @inbounds A[i] = sqrt(A[i]) end A end -stdm(A::AbstractArray, m::Number; corrected::Bool=true) = +stdm(A::AbstractArray, m::Number; corrected::Bool=true) = sqrt(varm(A, m; corrected=corrected)) -std(A::AbstractArray; corrected::Bool=true, mean=nothing) = +std(A::AbstractArray; corrected::Bool=true, mean=nothing) = sqrt(var(A; corrected=corrected, mean=mean)) -std(A::AbstractArray, region; corrected::Bool=true, mean=nothing) = +std(A::AbstractArray, region; corrected::Bool=true, mean=nothing) = sqrt!(var(A, region; corrected=corrected, mean=mean)) std(iterable; corrected::Bool=true, mean=nothing) = @@ -239,38 +239,38 @@ unscaled_covzm(x::AbstractVector) = dot(x, x) unscaled_covzm(x::AbstractMatrix, vardim::Int) = (vardim == 1 ? _conj(x'x) : x * x') unscaled_covzm(x::AbstractVector, y::AbstractVector) = dot(x, y) -unscaled_covzm(x::AbstractVector, y::AbstractMatrix, vardim::Int) = +unscaled_covzm(x::AbstractVector, y::AbstractMatrix, vardim::Int) = (vardim == 1 ? At_mul_B(x, _conj(y)) : At_mul_Bt(x, _conj(y))) -unscaled_covzm(x::AbstractMatrix, y::AbstractVector, vardim::Int) = +unscaled_covzm(x::AbstractMatrix, y::AbstractVector, vardim::Int) = (c = vardim == 1 ? At_mul_B(x, _conj(y)) : x * _conj(y); reshape(c, length(c), 1)) -unscaled_covzm(x::AbstractMatrix, y::AbstractMatrix, vardim::Int) = +unscaled_covzm(x::AbstractMatrix, y::AbstractMatrix, vardim::Int) = (vardim == 1 ? At_mul_B(x, _conj(y)) : A_mul_Bc(x, y)) # covzm (with centered data) covzm(x::AbstractVector; corrected::Bool=true) = unscaled_covzm(x, x) / (length(x) - int(corrected)) -covzm(x::AbstractMatrix; vardim::Int=1, corrected::Bool=true) = +covzm(x::AbstractMatrix; vardim::Int=1, corrected::Bool=true) = scale!(unscaled_covzm(x, vardim), inv(size(x,vardim) - int(corrected))) -covzm(x::AbstractVector, y::AbstractVector; corrected::Bool=true) = +covzm(x::AbstractVector, y::AbstractVector; corrected::Bool=true) = unscaled_covzm(x, y) / (length(x) - int(corrected)) -covzm(x::AbstractVecOrMat, y::AbstractVecOrMat; vardim::Int=1, corrected::Bool=true) = +covzm(x::AbstractVecOrMat, y::AbstractVecOrMat; vardim::Int=1, corrected::Bool=true) = scale!(unscaled_covzm(x, y, vardim), inv(_getnobs(x, y, vardim) - int(corrected))) # covm (with provided mean) -covm(x::AbstractVector, xmean; corrected::Bool=true) = +covm(x::AbstractVector, xmean; corrected::Bool=true) = covzm(x .- xmean; corrected=corrected) -covm(x::AbstractMatrix, xmean; vardim::Int=1, corrected::Bool=true) = +covm(x::AbstractMatrix, xmean; vardim::Int=1, corrected::Bool=true) = covzm(x .- xmean; vardim=vardim, corrected=corrected) -covm(x::AbstractVector, xmean, y::AbstractVector, ymean; corrected::Bool=true) = +covm(x::AbstractVector, xmean, y::AbstractVector, ymean; corrected::Bool=true) = covzm(x .- xmean, y .- ymean; corrected=corrected) -covm(x::AbstractVecOrMat, xmean, y::AbstractVecOrMat, ymean; vardim::Int=1, corrected::Bool=true) = +covm(x::AbstractVecOrMat, xmean, y::AbstractVecOrMat, ymean; vardim::Int=1, corrected::Bool=true) = covzm(x .- xmean, y .- ymean; vardim=vardim, corrected=corrected) # cov (API) @@ -352,7 +352,7 @@ end function cov2cor!(C::AbstractMatrix, xsd::AbstractArray, ysd::AbstractArray) nx, ny = size(C) - (length(xsd) == nx && length(ysd) == ny) || + (length(xsd) == nx && length(ysd) == ny) || throw(DimensionMismatch("Inconsistent dimensions.")) for j = 1:ny for i = 1:nx @@ -366,7 +366,7 @@ end corzm{T}(x::AbstractVector{T}) = float(one(T) * one(T)) -corzm(x::AbstractMatrix; vardim::Int=1) = +corzm(x::AbstractMatrix; vardim::Int=1) = (c = unscaled_covzm(x, vardim); cov2cor!(c, sqrt!(diag(c)))) function corzm(x::AbstractVector, y::AbstractVector) @@ -389,13 +389,13 @@ function corzm(x::AbstractVector, y::AbstractVector) return xy / (sqrt(xx) * sqrt(yy)) end -corzm(x::AbstractVector, y::AbstractMatrix; vardim::Int=1) = +corzm(x::AbstractVector, y::AbstractMatrix; vardim::Int=1) = cov2cor!(unscaled_covzm(x, y, vardim), sqrt(sumabs2(x)), sqrt!(sumabs2(y, vardim))) -corzm(x::AbstractMatrix, y::AbstractVector; vardim::Int=1) = +corzm(x::AbstractMatrix, y::AbstractVector; vardim::Int=1) = cov2cor!(unscaled_covzm(x, y, vardim), sqrt!(sumabs2(x, vardim)), sqrt(sumabs2(y))) -corzm(x::AbstractMatrix, y::AbstractMatrix; vardim::Int=1) = +corzm(x::AbstractMatrix, y::AbstractMatrix; vardim::Int=1) = cov2cor!(unscaled_covzm(x, y, vardim), sqrt!(sumabs2(x, vardim)), sqrt!(sumabs2(y, vardim))) # corm @@ -406,7 +406,7 @@ corm(x::AbstractMatrix, xmean; vardim::Int=1) = corzm(x .- xmean; vardim=vardim) corm(x::AbstractVector, xmean, y::AbstractVector, ymean) = corzm(x .- xmean, y .- ymean) -corm(x::AbstractVecOrMat, xmean, y::AbstractVecOrMat, ymean; vardim::Int=1) = +corm(x::AbstractVecOrMat, xmean, y::AbstractVecOrMat, ymean; vardim::Int=1) = corzm(x .- xmean, y .- ymean; vardim=vardim) # cor @@ -426,7 +426,7 @@ function cor(x::AbstractMatrix; vardim::Int=1, mean=nothing) end function cor(x::AbstractVector, y::AbstractVector; mean=nothing) - mean == 0 ? corzm(x, y) : + mean == 0 ? corzm(x, y) : mean == nothing ? corm(x, Base.mean(x), y, Base.mean(y)) : isa(mean, (Number,Number)) ? corm(x, mean[1], y, mean[2]) : error("Invalid value of mean.") @@ -435,7 +435,7 @@ end function cor(x::AbstractVecOrMat, y::AbstractVecOrMat; vardim::Int=1, mean=nothing) if mean == 0 corzm(x, y; vardim=vardim) - elseif mean == nothing + elseif mean == nothing corm(x, _vmean(x, vardim), y, _vmean(y, vardim); vardim=vardim) elseif isa(mean, (Any,Any)) corm(x, mean[1], y, mean[2]; vardim=vardim) @@ -613,7 +613,7 @@ hist(A::AbstractMatrix) = hist(A,sturges(size(A,1))) ## hist2d -function hist2d!{HT}(H::AbstractArray{HT,2}, v::AbstractMatrix, +function hist2d!{HT}(H::AbstractArray{HT,2}, v::AbstractMatrix, edg1::AbstractVector, edg2::AbstractVector; init::Bool=true) size(v,2) == 2 || error("hist2d requires an Nx2 matrix.") n = length(edg1) - 1 @@ -632,12 +632,12 @@ function hist2d!{HT}(H::AbstractArray{HT,2}, v::AbstractMatrix, edg1, edg2, H end -hist2d(v::AbstractMatrix, edg1::AbstractVector, edg2::AbstractVector) = +hist2d(v::AbstractMatrix, edg1::AbstractVector, edg2::AbstractVector) = hist2d!(Array(Int, length(edg1)-1, length(edg2)-1), v, edg1, edg2) hist2d(v::AbstractMatrix, edg::AbstractVector) = hist2d(v, edg, edg) -hist2d(v::AbstractMatrix, n1::Integer, n2::Integer) = +hist2d(v::AbstractMatrix, n1::Integer, n2::Integer) = hist2d(v, histrange(sub(v,:,1),n1), histrange(sub(v,:,2),n2)) hist2d(v::AbstractMatrix, n::Integer) = hist2d(v, n, n) hist2d(v::AbstractMatrix) = hist2d(v, sturges(size(v,1))) diff --git a/base/stream.jl b/base/stream.jl index 8aff047b423a5..5799fe4458537 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -10,7 +10,7 @@ abstract UVServer typealias UVHandle Ptr{Void} typealias UVStream AsyncStream -# A dict of all libuv handles that are being waited on somewhere in the system +# A dict of all libuv handles that are being waited on somewhere in the system # and should thus not be garbage collected const uvhandles = ObjectIdDict() @@ -144,7 +144,7 @@ type PipeServer <: UVServer end function init_pipe!(pipe::Union(Pipe,PipeServer);readable::Bool=false,writable=false,julia_only=true) - if pipe.handle == C_NULL + if pipe.handle == C_NULL error("failed to initialize pipe") elseif pipe.status != StatusUninit error("pipe is already initialized") @@ -200,7 +200,7 @@ function TTY(fd::RawFD; readable::Bool = false) ret = TTY(handle) associate_julia_struct(handle,ret) finalizer(ret,uvfinalize) - # This needs to go after associate_julia_struct so that there + # This needs to go after associate_julia_struct so that there # is no garbage in the ->data field uv_error("TTY",ccall(:uv_tty_init,Int32,(Ptr{Void},Ptr{Void},Int32,Int32),eventloop(),handle,fd.fd,readable)) ret.status = StatusOpen @@ -229,10 +229,10 @@ handle(s::Ptr{Void}) = s make_stdout_stream() = _uv_tty2tty(ccall(:jl_stdout_stream, Ptr{Void}, ())) -associate_julia_struct(handle::Ptr{Void},jlobj::ANY) = +associate_julia_struct(handle::Ptr{Void},jlobj::ANY) = ccall(:jl_uv_associate_julia_struct,Void,(Ptr{Void},Any),handle,jlobj) disassociate_julia_struct(uv) = disassociate_julia_struct(uv.handle) -disassociate_julia_struct(handle::Ptr{Void}) = +disassociate_julia_struct(handle::Ptr{Void}) = handle != C_NULL && ccall(:jl_uv_disassociate_julia_struct,Void,(Ptr{Void},),handle) function init_stdio(handle) @@ -250,7 +250,7 @@ function init_stdio(handle) error("FATAL: stdio type ($t) invalid") end ret.status = StatusOpen - ret.line_buffered = false + ret.line_buffered = false associate_julia_struct(ret.handle,ret) finalizer(ret,uvfinalize) return ret @@ -385,11 +385,11 @@ function notify_filled(stream::AsyncStream, nread::Int) end end -const READ_BUFFER_SZ=10485760 # 10 MB +const READ_BUFFER_SZ=10485760 # 10 MB function _uv_hook_readcb(stream::AsyncStream, nread::Int, base::Ptr{Void}, len::UInt) if nread < 0 if nread != UV_EOF - # This is a fatal connectin error. Shutdown requests as per the usual + # This is a fatal connectin error. Shutdown requests as per the usual # close function won't work and libuv will fail with an assertion failure ccall(:jl_forceclose_uv,Void,(Ptr{Void},),stream.handle) notify_error(stream.readnotify, UVError("readcb",nread)) @@ -408,9 +408,9 @@ function _uv_hook_readcb(stream::AsyncStream, nread::Int, base::Ptr{Void}, len:: notify(stream.readnotify) end - # Stop reading when + # Stop reading when # 1) when we have an infinite buffer, and we have accumulated a lot of unread data OR - # 2) we have an alternate buffer that has reached its limit. + # 2) we have an alternate buffer that has reached its limit. if (is_maxsize_unlimited(stream.buffer) && (nb_available(stream.buffer) > READ_BUFFER_SZ )) || (nb_available(stream.buffer) == stream.buffer.maxsize) stop_reading(stream) @@ -541,7 +541,7 @@ function process_events(block::Bool) end ## pipe functions ## -function malloc_julia_pipe(x) +function malloc_julia_pipe(x) x.handle = c_malloc(_sizeof_uv_named_pipe) associate_julia_struct(x.handle,x) finalizer(x,uvfinalize) @@ -665,30 +665,30 @@ function read!(s::AsyncStream, a::Vector{UInt8}) sbuf = s.buffer @assert sbuf.seekable == false @assert sbuf.maxsize >= nb - + if nb_available(sbuf) >= nb return read!(sbuf, a) end - + if nb <= 65536 # Arbitrary 64K limit under which we are OK with copying the array from the stream's buffer wait_readnb(s,nb) read!(sbuf, a) else stop_reading(s) # Just playing it safe, since we are going to switch buffers. - newbuf = PipeBuffer(a, nb) + newbuf = PipeBuffer(a, nb) newbuf.size = 0 s.buffer = newbuf - write(newbuf, sbuf) + write(newbuf, sbuf) wait_readnb(s,nb) s.buffer = sbuf end return a end -function read{T}(s::AsyncStream, ::Type{T}, dims::Dims) +function read{T}(s::AsyncStream, ::Type{T}, dims::Dims) isbits(T) || error("read from buffer only supports bits types or arrays of bits types") nb = prod(dims)*sizeof(T) - a = read!(s, Array(UInt8, nb)) + a = read!(s, Array(UInt8, nb)) reshape(reinterpret(T, a), dims) end @@ -801,7 +801,7 @@ function write(s::AsyncStream, p::Ptr, nb::Integer) return int(nb) end -function _uv_hook_writecb_task(s::AsyncStream,req::Ptr{Void},status::Int32) +function _uv_hook_writecb_task(s::AsyncStream,req::Ptr{Void},status::Int32) d = uv_req_data(req) if status < 0 err = UVError("write",status) @@ -850,7 +850,7 @@ function accept_nonblock(server::PipeServer) end function accept(server::UVServer, client::AsyncStream) - if server.status != StatusActive + if server.status != StatusActive throw(ArgumentError("server not connected; make sure \"listen\" has been called")) end while isopen(server) diff --git a/base/utf32.jl b/base/utf32.jl index 32ca92097d539..ca030e45c6310 100644 --- a/base/utf32.jl +++ b/base/utf32.jl @@ -72,7 +72,7 @@ convert{T<:Union(Int32,UInt32,Char)}(::Type{Ptr{T}}, s::UTF32String) = function convert(T::Type{UTF32String}, bytes::AbstractArray{UInt8}) isempty(bytes) && return UTF32String(Char[0]) length(bytes) & 3 != 0 && throw(ArgumentError("need multiple of 4 bytes")) - data = reinterpret(Char, bytes) + data = reinterpret(Char, bytes) # check for byte-order mark (BOM): if data[1] == char(0x0000feff) # native byte order d = Array(Char, length(data)) diff --git a/base/utf8proc.jl b/base/utf8proc.jl index 38e91de29042d..dc17288c47ee2 100644 --- a/base/utf8proc.jl +++ b/base/utf8proc.jl @@ -69,7 +69,7 @@ let s, 0, p, flags | UTF8PROC_NULLTERM) result < 0 && error(bytestring(ccall(:utf8proc_errmsg, Ptr{UInt8}, (Cssize_t,), result))) - a = ccall(:jl_ptr_to_array_1d, Vector{UInt8}, + a = ccall(:jl_ptr_to_array_1d, Vector{UInt8}, (Any, Ptr{UInt8}, Csize_t, Cint), Vector{UInt8}, p[1], result, true) ccall(:jl_array_to_string, Any, (Any,), a)::ByteString @@ -109,7 +109,7 @@ function normalize_string(s::AbstractString, nf::Symbol) | UTF8PROC_COMPAT) : throw(ArgumentError(":$nf is not one of :NFC, :NFD, :NFKC, :NFKD"))) end - + # returns UTF8PROC_CATEGORY code in 1:30 giving Unicode category function category_code(c) uint32(c) > 0x10FFFF && return 0x0000 # see utf8proc_get_property docs diff --git a/base/version.jl b/base/version.jl index 8a064770b60a4..2e806364dc2a7 100644 --- a/base/version.jl +++ b/base/version.jl @@ -96,7 +96,7 @@ end convert(::Type{VersionNumber}, v::AbstractString) = VersionNumber(v) -macro v_str(v); VersionNumber(v); end +macro v_str(v); VersionNumber(v); end typemin(::Type{VersionNumber}) = v"0-" typemax(::Type{VersionNumber}) = VersionNumber(typemax(Int),typemax(Int),typemax(Int),(),("",)) diff --git a/contrib/BBEditTextWrangler-julia.plist b/contrib/BBEditTextWrangler-julia.plist index cb1c58ab1f65e..931e97936a667 100644 --- a/contrib/BBEditTextWrangler-julia.plist +++ b/contrib/BBEditTextWrangler-julia.plist @@ -4,13 +4,13 @@ - - + BBEditDocumentType CodelessLanguageModule @@ -31,13 +31,13 @@ BBLMColorsSyntax - + BBLMScansFunctions BBLMKeywordList - + abstract baremodule begin @@ -69,12 +69,12 @@ typealias using while - - - + + + typeof - + @MIME @MIME_str @__FILE__ @@ -1128,7 +1128,7 @@ - + BBLMPredefinedNameList AbstractMatrix @@ -1286,20 +1286,20 @@ Identifier and Keyword Character Class A-Za-z0-9_! - + Escape Char in Strings 1 \ End-of-line Ends Strings 1 - + End-of-line Ends Strings 2 - + Function Pattern ^\s*) (?P function\s+ @@ -1312,7 +1312,7 @@ ) ]]> - + String Pattern - + Comment Pattern Base - Core - Main + Core + Main FFTW Collections diff --git a/examples/Makefile b/examples/Makefile index 08035fa3b02ea..c481347082774 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -5,7 +5,7 @@ override CFLAGS += $(JCFLAGS) override CXXFLAGS += $(JCXXFLAGS) FLAGS = -Wall -Wno-strict-aliasing -fno-omit-frame-pointer \ - -I$(JULIAHOME)/src -I$(JULIAHOME)/src/support -I$(build_includedir) $(CFLAGS) + -I$(JULIAHOME)/src -I$(JULIAHOME)/src/support -I$(build_includedir) $(CFLAGS) DEBUGFLAGS += $(FLAGS) SHIPFLAGS += $(FLAGS) diff --git a/examples/hpl.jl b/examples/hpl.jl index fbcbae00d1f8f..3c146a511a48f 100644 --- a/examples/hpl.jl +++ b/examples/hpl.jl @@ -7,13 +7,13 @@ function hpl_seq(A::Matrix, b::Vector) n = size(A,1) A = [A b] - + B_rows = linspace(0, n, div(n,blocksize)+1) - B_rows[end] = n + B_rows[end] = n B_cols = [B_rows, [n+1]] nB = length(B_rows) depend = zeros(Bool, nB, nB) # In parallel, depend needs to be able to hold futures - + ## Small matrix case if nB <= 1 x = A[1:n, 1:n] \ A[:,n+1] @@ -22,27 +22,27 @@ function hpl_seq(A::Matrix, b::Vector) ## Add a ghost row of dependencies to boostrap the computation for j=1:nB; depend[1,j] = true; end - + for i=1:(nB-1) ## Threads for panel factorizations I = (B_rows[i]+1):B_rows[i+1] #(depend[i+1,i], panel_p) = spawn(panel_factor_seq, I, depend[i,i]) (depend[i+1,i], panel_p) = panel_factor_seq(A, I, depend[i,i]) - + ## Threads for trailing updates for j=(i+1):nB - J = (B_cols[j]+1):B_cols[j+1] + J = (B_cols[j]+1):B_cols[j+1] #depend[i+1,j] = spawn(trailing_update_seq, I, J, panel_p, depend[i+1,i],depend[i,j]) depend[i+1,j] = trailing_update_seq(A, I, J, panel_p, depend[i+1,i],depend[i,j]) end end - + ## Completion of the last diagonal block signals termination #wait(depend[nB, nB]) - + ## Solve the triangular system x = triu(A[1:n,1:n]) \ A[:,n+1] - + return x end ## hpl() @@ -55,16 +55,16 @@ function panel_factor_seq(A, I, col_dep) ## Enforce dependencies #wait(col_dep) - + ## Factorize a panel K = I[1]:n panel_p = lufact!(sub(A, K, I))[:p] # Economy mode - - ## Panel permutation + + ## Panel permutation panel_p = K[panel_p] - + return (true, panel_p) - + end ## panel_factor_seq() @@ -73,25 +73,25 @@ end ## panel_factor_seq() function trailing_update_seq(A, I, J, panel_p, row_dep, col_dep) n = size (A, 1) - + ## Enforce dependencies #wait(row_dep, col_dep) - - ## Apply permutation from pivoting - K = (I[end]+1):n + + ## Apply permutation from pivoting + K = (I[end]+1):n A[I[1]:n, J] = A[panel_p, J] - - ## Compute blocks of U + + ## Compute blocks of U L = tril(A[I,I],-1) + eye(length(I)) A[I, J] = L \ A[I, J] - + ## Trailing submatrix update if !isempty(K) - A[K,J] = A[K,J] - A[K,I]*A[I,J] + A[K,J] = A[K,J] - A[K,I]*A[I,J] end - + return true - + end ## trailing_update_seq() # This version is written for a shared memory implementation. @@ -106,17 +106,17 @@ function hpl_par(A::Matrix, b::Vector, blocksize::Integer, run_parallel::Bool) n = size(A,1) A = [A b] - + if blocksize < 1 throw(ArgumentError("hpl_par: invalid blocksize: $blocksize < 1")) end B_rows = linspace(0, n, div(n,blocksize)+1) - B_rows[end] = n + B_rows[end] = n B_cols = [B_rows, [n+1]] nB = length(B_rows) depend = cell(nB, nB) - + ## Small matrix case if nB <= 1 x = A[1:n, 1:n] \ A[:,n+1] @@ -137,7 +137,7 @@ function hpl_par(A::Matrix, b::Vector, blocksize::Integer, run_parallel::Bool) ## Write the factorized panel back to A A[K,I] = A_KI - ## Panel permutation + ## Panel permutation panel_p = K[panel_p] depend[i+1,i] = true @@ -152,7 +152,7 @@ function hpl_par(A::Matrix, b::Vector, blocksize::Integer, run_parallel::Bool) for j=(i+1):nB J = (B_cols[j]+1):B_cols[j+1] - + ## Do the trailing update (Compute U, and DGEMM - all flops are here) if run_parallel A_IJ = A[I,J] @@ -178,13 +178,13 @@ function hpl_par(A::Matrix, b::Vector, blocksize::Integer, run_parallel::Bool) end end - + ## Completion of the last diagonal block signals termination @assert depend[nB, nB] - + ## Solve the triangular system x = triu(A[1:n,1:n]) \ A[:,n+1] - + return x end ## hpl() @@ -195,23 +195,23 @@ end ## hpl() function panel_factor_par(A_KI, col_dep) @assert col_dep - + ## Factorize a panel panel_p = lufact!(A_KI)[:p] # Economy mode - + return (A_KI, panel_p) - + end ## panel_factor_par() ### Trailing update ### function trailing_update_par(L_II, A_IJ, A_KI, A_KJ, row_dep, col_dep) - + @assert row_dep @assert col_dep - ## Compute blocks of U + ## Compute blocks of U A_IJ = L_II \ A_IJ ## Trailing submatrix update - All flops are here @@ -221,9 +221,9 @@ function trailing_update_par(L_II, A_IJ, A_KI, A_KJ, row_dep, col_dep) blas_gemm('N','N',m,n,k,-1.0,A_KI,m,A_IJ,k,1.0,A_KJ,m) #A_KJ = A_KJ - A_KI*A_IJ end - + return (A_IJ, A_KJ) - + end ## trailing_update_par() @@ -288,7 +288,7 @@ function hpl_par2(A::Matrix, b::Vector) end end end - + A = convert(Array, C) x = triu(A[1:n,1:n]) \ A[:,n+1] end ## hpl_par2() @@ -343,7 +343,7 @@ function trailing_update_par2(C, L_II, C_KI, i, j, n, flag, dep) else #(C.dist[i+1] == n+2) ? (I = (C.dist[i]):n) : # (I = (C.dist[i]):(C.dist[i+1]-1)) - + I = (C.dist[i]):(C.dist[i+1]-1) J = (C.dist[j]):(C.dist[j+1]-1) K = (I[length(I)]+1):n @@ -353,7 +353,7 @@ function trailing_update_par2(C, L_II, C_KI, i, j, n, flag, dep) else C_KJ = zeros(0) end - + ## Compute blocks of U C_IJ = L_II \ C_IJ C[I,J] = C_IJ @@ -364,8 +364,8 @@ function trailing_update_par2(C, L_II, C_KI, i, j, n, flag, dep) blas_gemm('N','N',cm,cn,ck,-1.0,C_KI,cm,C_IJ,ck,1.0,C_KJ,cm) #C_KJ = C_KJ - C_KI*C_IJ C[K,J] = C_KJ - end - end + end + end end ## trailing_update_par2() ## Test n*n matrix on np processors diff --git a/examples/typetree.jl b/examples/typetree.jl index a2d5e7fc531b1..89278d336557d 100644 --- a/examples/typetree.jl +++ b/examples/typetree.jl @@ -88,8 +88,8 @@ function store_all_from(m::Module) end type_props(typ) = "" -type_props(typ::DataType) = string("<<", - typ.abstract ? " abstract" : " concrete", +type_props(typ::DataType) = string("<<", + typ.abstract ? " abstract" : " concrete", typ.mutable ? " mutable" : " immutable", typ.pointerfree ? " pointerfree" : "", " size:", typ.size, @@ -108,7 +108,7 @@ function print_tree(subtypes::Dict{String, TTNode}, pfx::String="") end -# TODO: optionally take module names in command line +# TODO: optionally take module names in command line # TODO: sort output # TODO: option to list subtrees of type tree, or other symbol types const types_tree = Dict{String, TTNode}() diff --git a/examples/wordcount.jl b/examples/wordcount.jl index e7fbaedb8b0fb..2e219efb56c39 100644 --- a/examples/wordcount.jl +++ b/examples/wordcount.jl @@ -1,11 +1,11 @@ # wordcount.jl -# -# Implementation of parallelized "word-count" of a text, inspired by the -# Hadoop WordCount example. Uses @spawn and fetch() to parallelize +# +# Implementation of parallelized "word-count" of a text, inspired by the +# Hadoop WordCount example. Uses @spawn and fetch() to parallelize # the "map" task. Reduce is currently done single-threaded. # # To run in parallel on a string stored in variable `text`: -# julia -p +# julia -p # julia> require("/examples/wordcount.jl") # julia> ...(define text)... # julia> counts=parallel_wordcount(text) @@ -13,10 +13,10 @@ # Or to run on a group of files, writing results to an output file: # julia -p # julia> require("/examples/wordcount.jl") -# julia> wordcount_files("/tmp/output.txt", "/tmp/input1.txt","/tmp/input2.txt",...) +# julia> wordcount_files("/tmp/output.txt", "/tmp/input1.txt","/tmp/input2.txt",...) # "Map" function. -# Takes a string. Returns a Dict with the number of times each word +# Takes a string. Returns a Dict with the number of times each word # appears in that string. function wordcount(text) words=split(text,[' ','\n','\t','-','.',',',':',';'],false) @@ -39,7 +39,7 @@ function wcreduce(wcs) return counts end -# Splits input string into nprocs() equal-sized chunks (last one rounds up), +# Splits input string into nprocs() equal-sized chunks (last one rounds up), # and @spawns wordcount() for each chunk to run in parallel. Then fetch()s # results and performs wcreduce(). function parallel_wordcount(text) diff --git a/src/alloc.c b/src/alloc.c index 48d4d12ca333e..57be5fcb1b901 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -142,7 +142,7 @@ static jl_value_t *jl_new_bits_internal(jl_value_t *dt, void *data, size_t *len) if (bt == jl_int32_type) return jl_box_int32(*(int32_t*)data); if (bt == jl_float64_type) return jl_box_float64(*(double*)data); - jl_value_t *v = + jl_value_t *v = (jl_value_t*)allocobj((NWORDS(LLT_ALIGN(nb,sizeof(void*)))+1)* sizeof(void*)); v->type = (jl_value_t*)bt; diff --git a/src/array.c b/src/array.c index ad661ab80dc15..96bc7b315a7da 100644 --- a/src/array.c +++ b/src/array.c @@ -591,7 +591,7 @@ static size_t limit_overallocation(jl_array_t *a, size_t alen, size_t newlen, si size_t xtra_elems_mem = (newlen - a->offset - alen - inc) * es; if (xtra_elems_mem > jl_arr_xtralloc_limit) { // prune down - return alen + inc + a->offset + (jl_arr_xtralloc_limit / es); + return alen + inc + a->offset + (jl_arr_xtralloc_limit / es); } return newlen; } @@ -605,7 +605,7 @@ void jl_array_grow_end(jl_array_t *a, size_t inc) size_t newlen = a->maxsize==0 ? (inc<4?4:inc) : a->maxsize*2; while ((alen + inc) > newlen - a->offset) newlen *= 2; - + newlen = limit_overallocation(a, alen, newlen, inc); array_resize_buffer(a, newlen, alen, a->offset); } @@ -665,7 +665,7 @@ void jl_array_grow_beg(jl_array_t *a, size_t inc) size_t newlen = a->maxsize==0 ? inc*2 : a->maxsize*2; while (alen+2*inc > newlen-a->offset) newlen *= 2; - + newlen = limit_overallocation(a, alen, newlen, 2*inc); size_t center = (newlen - (alen + inc))/2; array_resize_buffer(a, newlen, alen, center+inc); diff --git a/src/ast.c b/src/ast.c index 773193375d40f..f743641d1cf73 100644 --- a/src/ast.c +++ b/src/ast.c @@ -120,7 +120,7 @@ DLLEXPORT void jl_init_frontend(void) value_t img = cvalue(iostreamtype, sizeof(ios_t)); ios_t *pi = value2c(ios_t*, img); ios_static_buffer(pi, (char*)flisp_system_image, sizeof(flisp_system_image)); - + if (fl_load_system_image(img)) { JL_PRINTF(JL_STDERR, "fatal error loading system image\n"); jl_exit(1); @@ -295,7 +295,7 @@ static jl_value_t *scm_to_julia_(value_t e, int eo) value_t largs = car_(e); jl_cellset(ex->args, 0, full_list(largs,eo)); e = cdr_(e); - + value_t ee = car_(e); jl_array_t *vinf = jl_alloc_cell_1d(3); jl_cellset(vinf, 0, full_list(car_(ee),eo)); @@ -306,7 +306,7 @@ static jl_value_t *scm_to_julia_(value_t e, int eo) assert(!iscons(cdr_(ee))); jl_cellset(ex->args, 1, vinf); e = cdr_(e); - + for(i=2; i < n; i++) { assert(iscons(e)); jl_cellset(ex->args, i, scm_to_julia_(car_(e), eo)); @@ -367,7 +367,7 @@ static jl_value_t *scm_to_julia_(value_t e, int eo) return *(jl_value_t**)cv_data((cvalue_t*)ptr(e)); } jl_error("malformed tree"); - + return (jl_value_t*)jl_null; } @@ -466,7 +466,7 @@ DLLEXPORT jl_value_t *jl_parse_input_line(const char *str) value_t e = fl_applyn(1, symbol_value(symbol("jl-parse-string")), s); if (e == FL_EOF) return jl_nothing; - + return scm_to_julia(e,0); } diff --git a/src/builtins.c b/src/builtins.c index dd987e1ad1bf6..101b3923eb094 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -776,7 +776,7 @@ void jl_show(jl_value_t *stream, jl_value_t *v) } if (jl_show_gf==NULL || stream==NULL) { JL_PRINTF(JL_STDERR, " could not show value of type %s", - jl_is_tuple(v) ? "Tuple" : + jl_is_tuple(v) ? "Tuple" : ((jl_datatype_t*)jl_typeof(v))->name->name->name); return; } @@ -1011,7 +1011,7 @@ void jl_init_primitives(void) add_builtin_func("eval", jl_f_top_eval); add_builtin_func("isdefined", jl_f_isdefined); add_builtin_func("yieldto", jl_f_yieldto); - + // functions for internal use add_builtin_func("tupleref", jl_f_tupleref); add_builtin_func("tuplelen", jl_f_tuplelen); diff --git a/src/ccall.cpp b/src/ccall.cpp index 9788e7e4accdb..f50cbb2b6c041 100644 --- a/src/ccall.cpp +++ b/src/ccall.cpp @@ -452,7 +452,7 @@ static native_sym_arg_t interpret_symbol_arg(jl_value_t *arg, jl_codectx_t *ctx, jl_value_t *ptr_ty = expr_type(arg, ctx); Value *arg1 = emit_unboxed(arg, ctx); if (!jl_is_cpointer_type(ptr_ty)) { - emit_cpointercheck(arg1, + emit_cpointercheck(arg1, !strcmp(fname,"ccall") ? "ccall: first argument not a pointer or valid constant expression" : "cglobal: first argument not a pointer or valid constant expression", @@ -512,7 +512,7 @@ static native_sym_arg_t interpret_symbol_arg(jl_value_t *arg, jl_codectx_t *ctx, #ifdef LLVM33 typedef AttributeSet attr_type; -#else +#else typedef AttrListPtr attr_type; #endif @@ -711,7 +711,7 @@ static Value *emit_llvmcall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx) for (std::vector::iterator it = argtypes.begin(); it != argtypes.end(); ++it) { if (!first) argstream << ","; - else + else first = false; (*it)->print(argstream); argstream << " "; @@ -930,11 +930,11 @@ static Value *emit_ccall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx) if (jl_signed_type == NULL) { jl_signed_type = jl_get_global(jl_core_module,jl_symbol("Signed")); } -#if LLVM33 +#if LLVM33 Attribute::AttrKind av; -#elif LLVM32 +#elif LLVM32 Attributes::AttrVal av; -#else +#else Attribute::AttrConst av; #endif #if LLVM32 && !LLVM33 @@ -991,7 +991,7 @@ static Value *emit_ccall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx) nargs--; } } - + if ((!isVa && jl_tuple_len(tt) != (nargs-2)/2) || ( isVa && jl_tuple_len(tt)-1 > (nargs-2)/2)) jl_error("ccall: wrong number of arguments to C function"); @@ -1247,7 +1247,7 @@ static Value *emit_ccall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx) } ctx->argDepth = last_depth; if (0) { // Enable this to turn on SSPREQ (-fstack-protector) on the function containing this ccall -#if LLVM32 && !LLVM33 +#if LLVM32 && !LLVM33 ctx->f->addFnAttr(Attributes::StackProtectReq); #else ctx->f->addFnAttr(Attribute::StackProtectReq); diff --git a/src/cgutils.cpp b/src/cgutils.cpp index eafb2bd0d25b6..5b317eff7c0a7 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -863,7 +863,7 @@ static Value *emit_nthptr_recast(Value *v, size_t n, MDNode *tbaa, Type* ptype) } static Value *ghostValue(jl_value_t *ty); - + static Value *typed_load(Value *ptr, Value *idx_0based, jl_value_t *jltype, jl_codectx_t *ctx) { diff --git a/src/codegen.cpp b/src/codegen.cpp index 359438894951c..c869c3adbbcee 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -73,13 +73,13 @@ #include "llvm/IR/MDBuilder.h" #define LLVM33 1 #else -#include "llvm/DerivedTypes.h" +#include "llvm/DerivedTypes.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Intrinsics.h" #include "llvm/Attributes.h" #endif -#if defined(LLVM_VERSION_MAJOR) && LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 2 +#if defined(LLVM_VERSION_MAJOR) && LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 2 #ifndef LLVM35 #include "llvm/DebugInfo.h" #include "llvm/DIBuilder.h" @@ -198,7 +198,7 @@ static std::map argNumberStrings; static FunctionPassManager *FPM; #ifdef LLVM35 -static DataLayoutPass *jl_data_layout; +static DataLayoutPass *jl_data_layout; #elif defined(LLVM32) static DataLayout *jl_data_layout; #else @@ -364,8 +364,8 @@ struct jl_varinfo_t { jl_varinfo_t() : memvalue(NULL), SAvalue(NULL), passedAs(NULL), closureidx(-1), isAssigned(true), isCaptured(false), isSA(false), isVolatile(false), - isArgument(false), isGhost(false), hasGCRoot(false), escapes(true), - usedUndef(false), used(false), + isArgument(false), isGhost(false), hasGCRoot(false), escapes(true), + usedUndef(false), used(false), declType((jl_value_t*)jl_any_type), initExpr(NULL) { } @@ -380,7 +380,7 @@ void jl_dump_bitcode(char *fname) #ifdef LLVM36 std::error_code err; StringRef fname_ref = StringRef(fname); - raw_fd_ostream OS(fname_ref, err, sys::fs::F_None); + raw_fd_ostream OS(fname_ref, err, sys::fs::F_None); #elif LLVM35 std::string err; raw_fd_ostream OS(fname, err, sys::fs::F_None); @@ -403,7 +403,7 @@ void jl_dump_objfile(char *fname, int jit_model) #ifdef LLVM36 std::error_code err; StringRef fname_ref = StringRef(fname); - raw_fd_ostream OS(fname_ref, err, sys::fs::F_None); + raw_fd_ostream OS(fname_ref, err, sys::fs::F_None); #elif LLVM35 std::string err; raw_fd_ostream OS(fname, err, sys::fs::F_None); @@ -664,7 +664,7 @@ extern "C" void jl_generate_fptr(jl_function_t *f) #endif Function *llvmf = (Function*)li->functionObject; - + #ifdef USE_MCJIT li->fptr = (jl_fptr_t)jl_ExecutionEngine->getFunctionAddress(llvmf->getName()); #else @@ -812,17 +812,17 @@ const jl_value_t *jl_dump_llvmf(void *f, bool dumpasm) JL_PRINTF(JL_STDERR, "Warning: Unable to find function pointer\n"); return jl_cstr_to_string(const_cast("")); } - + jl_dump_function_asm((void*)fptr, fit->second.lengthAdr, fit->second.lines, fstream); #else // MCJIT version std::map objmap = jl_jit_events->getObjectMap(); std::map::iterator fit = objmap.find(fptr); - + if (fit == objmap.end()) { JL_PRINTF(JL_STDERR, "Warning: Unable to find ObjectFile for function\n"); return jl_cstr_to_string(const_cast("")); } - + object::SymbolRef::Type symtype; uint64_t symsize; uint64_t symaddr; @@ -849,7 +849,7 @@ const jl_value_t *jl_dump_llvmf(void *f, bool dumpasm) jl_dump_function_asm((void*)fptr, symsize, fit->second.object, fstream); } #endif // LLVM35 -#endif +#endif fstream.flush(); } return jl_cstr_to_string(const_cast(stream.str().c_str())); @@ -1035,7 +1035,7 @@ jl_value_t *jl_static_eval(jl_value_t *ex, void *ctx_, jl_module_t *mod, // The next part is probably valid, but it is untested //} else if (e->head == tuple_sym) { // size_t i; - // for (i = 0; i < jl_array_dim0(e->args); i++) + // for (i = 0; i < jl_array_dim0(e->args); i++) // if (jl_static_eval(jl_exprarg(e,i),ctx,mod,sp,ast,sparams,allow_alloc) == NULL) // return NULL; // return ex; @@ -1274,7 +1274,7 @@ static bool jltupleisbits(jl_value_t *jt, bool allow_unsized) for (size_t i = 0; i < ntypes; ++i) if (!jltupleisbits(jl_tupleref(jt,i),allow_unsized)) return false; - return true; + return true; } static bool jl_tupleref_nonallocating(jl_value_t *ty, jl_value_t *idx) @@ -1834,7 +1834,7 @@ static Value *emit_known_call(jl_value_t *ff, jl_value_t **args, size_t nargs, if (jl_is_tuple(tty) && ity==(jl_value_t*)jl_long_type) { if (ctx->vaStack && symbol_eq(args[1], ctx->vaName)) { Value *valen = emit_n_varargs(ctx); - Value *idx = emit_unbox(T_size, + Value *idx = emit_unbox(T_size, emit_unboxed(args[2], ctx),ity); idx = emit_bounds_check(idx, valen, ctx); idx = builder.CreateAdd(idx, ConstantInt::get(T_size, ctx->nReqArgs)); @@ -1926,7 +1926,7 @@ static Value *emit_known_call(jl_value_t *ff, jl_value_t **args, size_t nargs, #else size_t nwords = nargs+2; #endif - Value *tup = + Value *tup = builder.CreateCall(prepare_call(jlallocobj_func), ConstantInt::get(T_size, sizeof(void*)*nwords)); #ifdef OVERLAP_TUPLE_LEN @@ -2652,9 +2652,9 @@ static void emit_assignment(jl_value_t *l, jl_value_t *r, jl_codectx_t *ctx) if (bp != NULL) { Type *vt = bp->getType(); if (vt->isPointerTy() && vt->getContainedType(0)!=jl_pvalue_llvmt) { - // TODO: `rt` is techincally correct here, but sometimes we're not propagating type information + // TODO: `rt` is techincally correct here, but sometimes we're not propagating type information // properly, so `rt` is a union type, while LLVM know that it's not. However, in order for this to - // happen, we need to already be sure somewhere that we have the right type, so vi.declType is fine + // happen, we need to already be sure somewhere that we have the right type, so vi.declType is fine // even if not techincally correct. rval = emit_unbox(vt->getContainedType(0), emit_unboxed(r, ctx), vi.declType); } @@ -2669,7 +2669,7 @@ static void emit_assignment(jl_value_t *l, jl_value_t *r, jl_codectx_t *ctx) rval = emit_expr(r, ctx, true); // Make sure this is already boxed. If not, there was // something wrong in the earlier analysis as this should - // have been alloca'd + // have been alloca'd assert(rval->getType() == jl_pvalue_llvmt || rval->getType() == NoopType); } @@ -2752,7 +2752,7 @@ static Value *emit_expr(jl_value_t *expr, jl_codectx_t *ctx, bool isboxed, BasicBlock *bb = (*ctx->labels)[labelname]; assert(bb); builder.CreateBr(bb); - BasicBlock *after = BasicBlock::Create(getGlobalContext(), + BasicBlock *after = BasicBlock::Create(getGlobalContext(), "br", ctx->f); builder.SetInsertPoint(after); } @@ -3348,7 +3348,7 @@ static Function *gen_jlcall_wrapper(jl_lambda_info_t *lam, jl_expr_t *ast, Funct if (lty == T_void || lty->isEmptyTy()) continue; theNewArg = emit_unbox(lty, theArg, ty); - } + } else if (jl_is_tuple(ty)) { Type *lty = julia_struct_to_llvm(ty); if (lty != jl_pvalue_llvmt) { @@ -3528,7 +3528,7 @@ static Function *emit_function(jl_lambda_info_t *lam, bool cstyle) if (!imaging_mode) { m = new Module(funcName.str(), jl_LLVMContext); jl_setup_module(m,true); - } + } else { m = shadow_module; } @@ -4033,7 +4033,7 @@ static Function *emit_function(jl_lambda_info_t *lam, bool cstyle) retval = boxed(emit_expr(jl_exprarg(ex,0), &ctx, true),&ctx,expr_type(stmt,&ctx)); } else if (retty != T_void) { - retval = emit_unbox(retty, + retval = emit_unbox(retty, emit_unboxed(jl_exprarg(ex,0), &ctx), jlrettype); } else { @@ -4254,9 +4254,9 @@ static void init_julia_llvm_env(Module *m) , T_size #endif }; - Type* jl_array_llvmt = + Type* jl_array_llvmt = StructType::create(jl_LLVMContext, - ArrayRef(vaelts,sizeof(vaelts)/sizeof(vaelts[0])), + ArrayRef(vaelts,sizeof(vaelts)/sizeof(vaelts[0])), "jl_array_t"); jl_parray_llvmt = PointerType::get(jl_array_llvmt,0); @@ -4298,7 +4298,7 @@ static void init_julia_llvm_env(Module *m) true, GlobalVariable::ExternalLinkage, NULL, "jl_uv_stderr"); add_named_global(jlstderr_var, (void*)&jl_uv_stderr); - + jlRTLD_DEFAULT_var = new GlobalVariable(*m, T_pint8, true, GlobalVariable::ExternalLinkage, @@ -4320,7 +4320,7 @@ static void init_julia_llvm_env(Module *m) // Has to be big enough for the biggest LLVM-supported float type jlfloattemp_var = new GlobalVariable(*m, IntegerType::get(jl_LLVMContext,128), - false, GlobalVariable::ExternalLinkage, + false, GlobalVariable::ExternalLinkage, ConstantInt::get(IntegerType::get(jl_LLVMContext,128),0), "jl_float_temp"); #endif @@ -4531,10 +4531,10 @@ static void init_julia_llvm_env(Module *m) Function::ExternalLinkage, "alloc_3w", m); add_named_global(jlalloc3w_func, (void*)&alloc_3w); - + std::vector atargs(0); atargs.push_back(T_size); - jl_alloc_tuple_func = + jl_alloc_tuple_func = Function::Create(FunctionType::get(jl_pvalue_llvmt, atargs, false), Function::ExternalLinkage, "jl_alloc_tuple", m); @@ -4594,14 +4594,14 @@ static void init_julia_llvm_env(Module *m) // set up optimization passes FPM = new FunctionPassManager(m); - + #ifdef LLVM36 jl_data_layout = new llvm::DataLayoutPass(); #elif LLVM35 jl_data_layout = new llvm::DataLayoutPass(*jl_ExecutionEngine->getDataLayout()); #elif defined(LLVM32) jl_data_layout = new DataLayout(*jl_ExecutionEngine->getDataLayout()); -#else +#else jl_data_layout = new TargetData(*jl_ExecutionEngine->getTargetData()); #endif FPM->add(jl_data_layout); @@ -4618,7 +4618,7 @@ static void init_julia_llvm_env(Module *m) // list of passes from vmkit FPM->add(createCFGSimplificationPass()); // Clean up disgusting code FPM->add(createPromoteMemoryToRegisterPass());// Kill useless allocas - + #ifndef INSTCOMBINE_BUG FPM->add(createInstructionCombiningPass()); // Cleanup for scalarrepl. #endif @@ -4633,7 +4633,7 @@ static void init_julia_llvm_env(Module *m) #ifndef INSTCOMBINE_BUG FPM->add(createInstructionCombiningPass()); // Combine silly seq's #endif - + //FPM->add(createCFGSimplificationPass()); // Merge & remove BBs FPM->add(createReassociatePass()); // Reassociate expressions @@ -4661,7 +4661,7 @@ static void init_julia_llvm_env(Module *m) FPM->add(createLoopUnrollPass()); // Unroll small loops #endif //FPM->add(createLoopStrengthReducePass()); // (jwb added) - + #if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 3 && !defined(INSTCOMBINE_BUG) FPM->add(createLoopVectorizePass()); // Vectorize loops #endif @@ -4669,9 +4669,9 @@ static void init_julia_llvm_env(Module *m) FPM->add(createInstructionCombiningPass()); // Clean up after the unroller #endif FPM->add(createGVNPass()); // Remove redundancies - //FPM->add(createMemCpyOptPass()); // Remove memcpy / form memset + //FPM->add(createMemCpyOptPass()); // Remove memcpy / form memset FPM->add(createSCCPPass()); // Constant prop with SCCP - + // Run instcombine after redundancy elimination to exploit opportunities // opened up by them. FPM->add(createSinkingPass()); ////////////// **** @@ -4738,7 +4738,7 @@ extern "C" void jl_init_codegen(void) //options.PrintMachineCode = true; //Print machine code produced during JIT compiling #ifdef JL_DEBUG_BUILD options.JITEmitDebugInfo = true; -#endif +#endif options.NoFramePointerElim = true; #ifndef LLVM34 options.NoFramePointerElimNonLeaf = true; @@ -4811,7 +4811,7 @@ extern "C" void jl_init_codegen(void) jl_jit_events = new JuliaJITEventListener(); jl_ExecutionEngine->RegisterJITEventListener(jl_jit_events); #ifdef JL_USE_INTEL_JITEVENTS - if (jl_using_intel_jitevents) + if (jl_using_intel_jitevents) jl_ExecutionEngine->RegisterJITEventListener( JITEventListener::createIntelJITEventListener()); #endif // JL_USE_INTEL_JITEVENTS diff --git a/src/debuginfo.cpp b/src/debuginfo.cpp index 7c8790993e32d..4fda8237cee92 100644 --- a/src/debuginfo.cpp +++ b/src/debuginfo.cpp @@ -120,7 +120,7 @@ class JuliaJITEventListener: public JITEventListener objectmap[Addr] = tmp; } #else - error_code itererr; + error_code itererr; object::symbol_iterator sym_iter = obj.begin_symbols(); object::symbol_iterator sym_end = obj.end_symbols(); for (; sym_iter != sym_end; sym_iter.increment(itererr)) { @@ -396,7 +396,7 @@ void jl_getDylibFunctionInfo(const char **name, size_t *line, const char **filen } else { const llvm::object::pe32_header *pe32; - coffobj->getPE32Header(pe32); + coffobj->getPE32Header(pe32); if (pe32 == NULL) { obj = NULL; context = NULL; @@ -580,7 +580,7 @@ class JITMemoryManagerWin : public JITMemoryManager { virtual void registerEHFrames(StringRef SectionData) { return JMM->registerEHFrames(SectionData); } }; -#else +#else void *CALLBACK jl_getUnwindInfo(HANDLE hProcess, ULONG64 AddrBase, ULONG64 UserContext) { return NULL; diff --git a/src/disasm.cpp b/src/disasm.cpp index 604aef2ce7b9b..72ca6deea07bd 100644 --- a/src/disasm.cpp +++ b/src/disasm.cpp @@ -34,7 +34,7 @@ class FuncMCView : public MemoryObject { uint64_t getBase() const { return 0; } uint64_t getExtent() const { return Fsize; } - + int readByte(uint64_t Addr, uint8_t *Byte) const { if (Addr >= getExtent()) return -1; @@ -60,7 +60,7 @@ void jl_dump_function_asm(void *Fptr, size_t Fsize, // Avoids hard-coded targets - will generally be only host CPU anyway. llvm::InitializeNativeTargetAsmParser(); llvm::InitializeNativeTargetDisassembler(); - + // Get the host information std::string TripleName; if (TripleName.empty()) @@ -74,7 +74,7 @@ void jl_dump_function_asm(void *Fptr, size_t Fsize, std::string err; const Target* TheTarget = TargetRegistry::lookupTarget(TripleName, err); - // Set up required helpers and streamer + // Set up required helpers and streamer #ifdef LLVM35 std::unique_ptr Streamer; #else @@ -184,11 +184,11 @@ void jl_dump_function_asm(void *Fptr, size_t Fsize, stream << "Filename: " << debugscope.getFilename() << "\n"; stream << "Source line: " << (*lineIter).Loc.getLine() << "\n"; } - + // Do the disassembly for (Index = 0, absAddr = (uint64_t)Fptr; Index < memoryObject.getExtent(); Index += Size, absAddr += Size) { - + if (nextLineAddr != (uint64_t)-1 && absAddr == nextLineAddr) { stream << "Source line: " << (*lineIter).Loc.getLine() << "\n"; nextLineAddr = (*++lineIter).Address; @@ -252,12 +252,12 @@ void jl_dump_function_asm(void *Fptr, size_t Fsize, uint64_t Index = 0; uint64_t absAddr = 0; - uint64_t insSize = 0; + uint64_t insSize = 0; // Do the disassembly for (Index = 0, absAddr = (uint64_t)Fptr; Index < memoryObject.getExtent(); Index += insSize, absAddr += insSize) { - + if (nextLineAddr != (uint64_t)-1 && absAddr == nextLineAddr) { #ifdef LLVM35 stream << "Source line: " << lineIter->second.Line << "\n"; diff --git a/src/dlload.c b/src/dlload.c index 9d5f4602bbe74..ef5332696e176 100644 --- a/src/dlload.c +++ b/src/dlload.c @@ -46,7 +46,7 @@ DLLEXPORT int jl_uv_dlopen(const char *filename, jl_uv_libhandle lib_, unsigned #endif #if defined(RTLD_GLOBAL) && defined(RTLD_LAZY) /* POSIX flags available */ dlerror(); /* Reset error status. */ - lib->handle = dlopen(filename, + lib->handle = dlopen(filename, (flags & JL_RTLD_NOW ? RTLD_NOW : RTLD_LAZY) | JL_RTLD(flags, GLOBAL) | JL_RTLD(flags, LOCAL) #ifdef RTLD_NODELETE diff --git a/src/flisp/Windows.mk b/src/flisp/Windows.mk index 444ab2aa1e8c6..fb61dc9d760dc 100644 --- a/src/flisp/Windows.mk +++ b/src/flisp/Windows.mk @@ -13,7 +13,7 @@ SOURCES = \ julia_extensions.c \ dirname.c \ basename.c - + HEADERS = \ flisp.h \ opcodes.h \ @@ -42,7 +42,7 @@ LFLAGS = $(LFLAGS) kernel32.lib ws2_32.lib psapi.lib advapi32.lib iphlpapi.lib default: $(NAME).exe $(NAME).exe: lib$(NAME).lib flmain.obj $(LIBSUPPORT) $(LIBUV) $(LIBMOJIBAKE) - $(LINK) $(LFLAGS) /OUT:$(NAME).exe /PDB:$(NAME).pdb /MAP $** + $(LINK) $(LFLAGS) /OUT:$(NAME).exe /PDB:$(NAME).pdb /MAP $** $(LIBSUPPORT): PUSHD $(MAKEDIR)\..\support && $(MAKE) /NOLOGO /F Windows.mk && POPD @@ -59,7 +59,7 @@ lib$(NAME).lib: $(OBJECTS) flisp.obj: flisp.c cvalues.c types.c flisp.h print.c read.c equal.c $(CC) $(CFLAGS) flisp.c -flmain.obj: flmain.c flisp.h +flmain.obj: flmain.c flisp.h $(CC) $(CFLAGS) flmain.c .c.obj: diff --git a/src/flisp/basename.c b/src/flisp/basename.c index 1363c1221a7e9..e1a256249e523 100644 --- a/src/flisp/basename.c +++ b/src/flisp/basename.c @@ -8,11 +8,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE diff --git a/src/flisp/compiler.lsp b/src/flisp/compiler.lsp index 35489122abee0..fdc516dce3ea8 100644 --- a/src/flisp/compiler.lsp +++ b/src/flisp/compiler.lsp @@ -2,32 +2,32 @@ (define Instructions (let ((e (table)) - (keys + (keys [nop dup pop call tcall jmp brf brt jmp.l brf.l brt.l ret - + eq? eqv? equal? atom? not null? boolean? symbol? number? bound? pair? builtin? vector? fixnum? function? - + cons list car cdr set-car! set-cdr! apply - + + - * / div0 = < compare - + vector aref aset! - + loadt loadf loadnil load0 load1 loadi8 loadv loadv.l loadg loadg.l loada loada.l loadc loadc.l setg setg.l seta seta.l removed-setc removed-setc.l - + closure argc vargc trycatch for tapply add2 sub2 neg largc lvargc loada0 loada1 loadc0 loadc1 call.l tcall.l brne brne.l cadr brnn brnn.l brn brn.l optargs brbound keyargs box box.l shift - + dummy_t dummy_f dummy_nil])) (for 0 (1- (length keys)) (lambda (i) @@ -180,7 +180,7 @@ largc lvargc call.l tcall.l box.l) (io.write bcode (int32 nxt)) (set! i (+ i 1))) - + ((optargs keyargs) ; 2 int32 args (io.write bcode (int32 nxt)) (set! i (+ i 1)) @@ -189,7 +189,7 @@ (if (eq? vi 'keyargs) (begin (io.write bcode (int32 (aref v i))) (set! i (+ i 1))))) - + (else ; other number arguments are always uint8 (io.write bcode (uint8 nxt)) @@ -825,43 +825,43 @@ ((loadv.l loadg.l setg.l) (print-val (aref vals (ref-int32-LE code i))) (set! i (+ i 4))) - + ((loadv loadg setg) (print-val (aref vals (aref code i))) (set! i (+ i 1))) - + ((loada seta loadc call tcall list + - * / vector argc vargc loadi8 apply tapply closure box shift) (princ (number->string (aref code i))) (set! i (+ i 1))) - + ((loada.l seta.l loadc.l largc lvargc call.l tcall.l box.l) (princ (number->string (ref-int32-LE code i))) (set! i (+ i 4))) - + ((optargs keyargs) (princ (number->string (ref-int32-LE code i)) " ") (set! i (+ i 4)) (princ (number->string (ref-int32-LE code i))) (set! i (+ i 4)) (if (eq? inst 'keyargs) - (begin + (begin (princ " ") (princ (number->string (ref-int32-LE code i)) " ") (set! i (+ i 4))))) - + ((brbound) (princ (number->string (ref-int32-LE code i)) " ") (set! i (+ i 4))) - + ((jmp brf brt brne brnn brn) (princ "@" (hex5 (+ i -4 (ref-int16-LE code i)))) (set! i (+ i 2))) - + ((jmp.l brf.l brt.l brne.l brnn.l brn.l) (princ "@" (hex5 (+ i -4 (ref-int32-LE code i)))) (set! i (+ i 4))) - + (else #f))))))) ; From SRFI 89 by Marc Feeley (http://srfi.schemers.org/srfi-89/srfi-89.html) diff --git a/src/flisp/dirname.c b/src/flisp/dirname.c index e3a3d13178c12..c6bd70ca54d14 100644 --- a/src/flisp/dirname.c +++ b/src/flisp/dirname.c @@ -8,11 +8,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE diff --git a/src/flisp/equal.c b/src/flisp/equal.c index ddb7167fb0f14..d313ff3965150 100644 --- a/src/flisp/equal.c +++ b/src/flisp/equal.c @@ -225,12 +225,12 @@ static value_t cyc_compare(value_t a, value_t b, htable_t *table, int eq) function_t *fb = (function_t*)ptr(b); d = bounded_compare(fa->bcode, fb->bcode, 1, eq); if (numval(d) != 0) return d; - + ca = eq_class(table, a); cb = eq_class(table, b); if (ca!=NIL && ca==cb) return fixnum(0); - + eq_union(table, a, b, ca, cb); d = cyc_compare(fa->vals, fb->vals, table, eq); if (numval(d) != 0) return d; diff --git a/src/flisp/flisp.c b/src/flisp/flisp.c index 0f1077250fe8e..98db950fc74e5 100644 --- a/src/flisp/flisp.c +++ b/src/flisp/flisp.c @@ -1804,20 +1804,20 @@ static value_t apply_cl(uint32_t nargs) assert(i < vector_size(v)); PUSH(vector_elt(v, i)); NEXT_OP; - + OP(OP_LOADC0) PUSH(vector_elt(Stack[bp+nargs], 0)); NEXT_OP; OP(OP_LOADC1) PUSH(vector_elt(Stack[bp+nargs], 1)); NEXT_OP; - + OP(OP_LOADCL) i = GET_INT32(ip); ip+=4; v = Stack[bp+nargs]; PUSH(vector_elt(v, i)); NEXT_OP; - + OP(OP_CLOSURE) n = *ip++; assert(n > 0); diff --git a/src/flisp/print.c b/src/flisp/print.c index cdd84cde336aa..4bdafc77ec63b 100644 --- a/src/flisp/print.c +++ b/src/flisp/print.c @@ -313,20 +313,20 @@ static void print_pair(ios_t *f, value_t v) thistiny = tinyp(car_(v)); ind = (((VPOS > lastv) || (HPOS>SCR_WIDTH/2 && !nextsmall && !thistiny && n>0)) || - + (HPOS > SCR_WIDTH-4) || - + (est!=-1 && (HPOS+est > SCR_WIDTH-2)) || - + ((head == LAMBDA) && !nextsmall) || - + (n > 0 && always) || - + (n == 2 && after3) || (n == 1 && after2) || (n_unindented >= 3 && !nextsmall) || - + (n == 0 && !smallp(head))); } diff --git a/src/flisp/system.lsp b/src/flisp/system.lsp index 667d0c03ff11b..995c8f689ab2d 100644 --- a/src/flisp/system.lsp +++ b/src/flisp/system.lsp @@ -710,7 +710,7 @@ (define (expand e) ; symbol resolves to toplevel; i.e. has no shadowing definition (define (top? s env) (not (or (bound? s) (assq s env)))) - + (define (splice-begin body) (cond ((atom? body) body) ((equal? body '((begin))) @@ -720,9 +720,9 @@ (append (splice-begin (cdar body)) (splice-begin (cdr body)))) (else (cons (car body) (splice-begin (cdr body)))))) - + (define *expanded* (list '*expanded*)) - + (define (expand-body body env) (if (atom? body) body (let* ((body (if (top? 'begin env) @@ -754,19 +754,19 @@ (set-car! body (cdar body))) (set! body (cdr body))) ex-nondefs))))) - + (define (expand-lambda-list l env) (if (atom? l) l (cons (if (and (pair? (car l)) (pair? (cdr (car l)))) (list (caar l) (expand-in (cadar l) env)) (car l)) (expand-lambda-list (cdr l) env)))) - + (define (l-vars l) (cond ((atom? l) (list l)) ((pair? (car l)) (cons (caar l) (l-vars (cdr l)))) (else (cons (car l) (l-vars (cdr l)))))) - + (define (expand-lambda e env) (let ((formals (cadr e)) (name (lastcdr e)) @@ -776,7 +776,7 @@ `(lambda ,(expand-lambda-list formals env) ,.(expand-body body env) . ,name)))) - + (define (expand-define e env) (if (or (null? (cdr e)) (atom? (cadr e))) (if (null? (cddr e)) @@ -789,7 +789,7 @@ (let ((env (nconc (map list vars) env))) `(define ,(cons name (expand-lambda-list formals env)) ,.(expand-body body env)))))) - + (define (expand-let-syntax e env) (let ((binds (cadr e))) (cons 'begin @@ -802,12 +802,12 @@ env)) binds) env))))) - + ; given let-syntax definition environment (menv) and environment ; at the point of the macro use (lenv), return the environment to ; expand the macro use in. TODO (define (local-expansion-env menv lenv) menv) - + (define (expand-in e env) (if (atom? e) e (let* ((head (car e)) diff --git a/src/gf.c b/src/gf.c index ee226d9ef3853..145fa0d45148a 100644 --- a/src/gf.c +++ b/src/gf.c @@ -643,7 +643,7 @@ static jl_function_t *cache_method(jl_methtable_t *mt, jl_tuple_t *type, might be passed. Since every type x has its own type Type{x}, this would be excessive specialization for an Any slot. - + TypeConstructors are problematic because they can be alternate representations of any type. Extensionally, TC == TC.body, but typeof(TC) != typeof(TC.body). This creates an ambiguity: @@ -651,7 +651,7 @@ static jl_function_t *cache_method(jl_methtable_t *mt, jl_tuple_t *type, x::TypeConstructor matches the first but not the second, while also matching all other TypeConstructors. This means neither Type{TC} nor TypeConstructor is more specific. - + To solve this, we identify "kind slots", which are slots for which some definition specifies a kind (e.g. DataType). Those tend to be in reflective functions that look at types @@ -1118,16 +1118,16 @@ void print_func_loc(JL_STREAM *s, jl_lambda_info_t *li); /* warn about ambiguous method priorities - + the relative priority of A and B is ambiguous if !subtype(A,B) && !subtype(B,A) && no corresponding tuple elements are disjoint. - + for example, (AbstractArray, AbstractMatrix) and (AbstractMatrix, AbstractArray) are ambiguous. however, (AbstractArray, AbstractMatrix, Foo) and (AbstractMatrix, AbstractArray, Bar) are fine since Foo and Bar are disjoint, so there would be no confusion over which one to call. - + There is also this kind of ambiguity: foo{T,S}(T, S) vs. foo(Any,Any) In this case jl_types_equal() is true, but one is jl_type_morespecific or jl_type_match_morespecific than the other. @@ -1609,7 +1609,7 @@ JL_CALLABLE(jl_apply_generic) jl_function_t *mfunc = jl_method_table_assoc_exact(mt, args, nargs); if (mfunc != jl_bottom_func) { - if (mfunc->linfo != NULL && + if (mfunc->linfo != NULL && (mfunc->linfo->inInference || mfunc->linfo->inCompile)) { // if inference is running on this function, return a copy // of the function to be compiled without inference and run. @@ -1691,7 +1691,7 @@ jl_value_t *jl_gf_invoke(jl_function_t *gf, jl_tuple_t *types, else mfunc = jl_method_table_assoc_exact(m->invokes, args, nargs); if (mfunc != jl_bottom_func) { - if (mfunc->linfo != NULL && + if (mfunc->linfo != NULL && (mfunc->linfo->inInference || mfunc->linfo->inCompile)) { // if inference is running on this function, return a copy // of the function to be compiled without inference and run. diff --git a/src/init.c b/src/init.c index 852dc878a4750..68b95e873c687 100644 --- a/src/init.c +++ b/src/init.c @@ -356,7 +356,7 @@ EXCEPTION_DISPOSITION _seh_exception_handler(PEXCEPTION_RECORD ExceptionRecord, EXCEPTION_POINTERS ExceptionInfo; ExceptionInfo.ExceptionRecord = ExceptionRecord; ExceptionInfo.ContextRecord = ContextRecord; - + EXCEPTION_DISPOSITION rval; switch (_exception_handler(&ExceptionInfo,1)) { case EXCEPTION_CONTINUE_EXECUTION: @@ -370,7 +370,7 @@ EXCEPTION_DISPOSITION _seh_exception_handler(PEXCEPTION_RECORD ExceptionRecord, } return rval; -} +} void* CALLBACK jl_getUnwindInfo(HANDLE hProcess, ULONG64 AddrBase, ULONG64 UserContext); #endif @@ -531,7 +531,7 @@ void *init_stdio_handle(uv_file fd,int readable) void *handle; uv_handle_type type = uv_guess_handle(fd); jl_uv_file_t *file; -#ifndef _OS_WINDOWS_ +#ifndef _OS_WINDOWS_ // Duplicate the file descriptor so we can later dup it over if we want to redirect // STDIO without having to worry about closing the associated libuv object. // On windows however, libuv objects remember streams by their HANDLE, so this is @@ -549,7 +549,7 @@ void *init_stdio_handle(uv_file fd,int readable) ((uv_tty_t*)handle)->data=0; uv_tty_set_mode((uv_tty_t*)handle,0); //cooked stdio break; - case UV_FILE: + case UV_FILE: file = (jl_uv_file_t*)malloc(sizeof(jl_uv_file_t)); file->loop = jl_io_loop; file->type = UV_FILE; @@ -602,7 +602,7 @@ char jl_using_intel_jitevents; // Non-zero if running under Intel VTune Amplifie #endif #if defined(JL_USE_INTEL_JITEVENTS) && defined(__linux__) -unsigned sig_stack_size = SIGSTKSZ; +unsigned sig_stack_size = SIGSTKSZ; #else #define sig_stack_size SIGSTKSZ #endif @@ -730,7 +730,7 @@ void julia_init(char *imageFile) jl_io_loop = uv_default_loop(); // this loop will internal events (spawning process etc.), // best to call this first, since it also initializes libuv jl_page_size = jl_getpagesize(); - jl_arr_xtralloc_limit = uv_get_total_memory() / 100; // Extra allocation limited to 1% of total RAM + jl_arr_xtralloc_limit = uv_get_total_memory() / 100; // Extra allocation limited to 1% of total RAM jl_find_stack_bottom(); jl_dl_handle = (uv_lib_t *) jl_load_dynamic_library(NULL, JL_RTLD_DEFAULT); #ifdef RTLD_DEFAULT @@ -774,8 +774,8 @@ void julia_init(char *imageFile) jl_using_intel_jitevents = 1; #if defined(__linux__) // Intel VTune Amplifier needs at least 64k for alternate stack. - if (SIGSTKSZ < 1<<16) - sig_stack_size = 1<<16; + if (SIGSTKSZ < 1<<16) + sig_stack_size = 1<<16; #endif } #endif @@ -891,13 +891,13 @@ void julia_init(char *imageFile) pthread_attr_t attr; if (pthread_attr_init(&attr) != 0) { JL_PRINTF(JL_STDERR, "pthread_attr_init failed"); - jl_exit(1); + jl_exit(1); } pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED); if (pthread_create(&thread,&attr,mach_segv_listener,NULL) != 0) { JL_PRINTF(JL_STDERR, "pthread_create failed"); - jl_exit(1); - } + jl_exit(1); + } pthread_attr_destroy(&attr); ret = thread_set_exception_ports(mach_thread_self(),EXC_MASK_BAD_ACCESS,segv_port,EXCEPTION_DEFAULT,MACHINE_THREAD_STATE); diff --git a/src/intrinsics.cpp b/src/intrinsics.cpp index a171a1b3a10e2..cf1a6165a4a2c 100644 --- a/src/intrinsics.cpp +++ b/src/intrinsics.cpp @@ -72,7 +72,7 @@ static Type *FTnbits(size_t nb) return Type::getDoubleTy(jl_LLVMContext); else if (nb == 128) return Type::getFP128Ty(jl_LLVMContext); - else + else jl_error("Unsupported Float Size"); } // convert int type to same-size float type @@ -948,7 +948,7 @@ static Value *emit_intrinsic(intrinsic f, jl_value_t **args, size_t nargs, HANDLE(fpext,2) { Value *x = auto_unbox(args[2],ctx); #if JL_NEED_FLOATTEMP_VAR - // Target platform might carry extra precision. + // Target platform might carry extra precision. // Force rounding to single precision first. The reason is that it's // fine to keep working in extended precision as long as it's // understood that everything is implicitly rounded to 23 bits, diff --git a/src/jl_uv.c b/src/jl_uv.c index 00531415ffc4f..9d9c94dfb96a2 100644 --- a/src/jl_uv.c +++ b/src/jl_uv.c @@ -294,7 +294,7 @@ DLLEXPORT void jl_close_uv(uv_handle_t *handle) * a) In case the stream is already shut down, in which case we're likely * in the process of closing this stream (since there's no other call to * uv_shutdown). - * b) In case the stream is already closed, in which case uv_close would + * b) In case the stream is already closed, in which case uv_close would * cause an assertion failure. */ uv_shutdown(req, (uv_stream_t*)handle, &jl_uv_shutdownCallback); @@ -336,7 +336,7 @@ DLLEXPORT int jl_spawn(char *name, char **argv, uv_loop_t *loop, uv_process_t *proc, jl_value_t *julia_struct, uv_handle_type stdin_type, uv_pipe_t *stdin_pipe, uv_handle_type stdout_type, uv_pipe_t *stdout_pipe, - uv_handle_type stderr_type, uv_pipe_t *stderr_pipe, + uv_handle_type stderr_type, uv_pipe_t *stderr_pipe, int detach, char **env, char *cwd) { uv_process_options_t opts; @@ -400,7 +400,7 @@ DLLEXPORT int jl_fs_poll_start(uv_fs_poll_t *handle, char *file, uint32_t interv DLLEXPORT int jl_fs_event_init(uv_loop_t *loop, uv_fs_event_t *handle, const char *filename, int flags) { - uv_fs_event_init(loop,handle); + uv_fs_event_init(loop,handle); return uv_fs_event_start(handle,&jl_uv_fseventscb,filename,flags); } @@ -957,7 +957,7 @@ DLLEXPORT int jl_ispty(uv_pipe_t *pipe) int n = 0; if (!strncmp(name,"\\\\?\\pipe\\msys-",14)) n = 14; - else if (!strncmp(name,"\\\\?\\pipe\\cygwin-",16)) + else if (!strncmp(name,"\\\\?\\pipe\\cygwin-",16)) n = 16; else return 0; @@ -974,7 +974,7 @@ DLLEXPORT int jl_ispty(uv_pipe_t *pipe) return 1; } #endif - + DLLEXPORT uv_handle_type jl_uv_handle_type(uv_handle_t *handle) { #ifdef _OS_WINDOWS_ @@ -999,8 +999,8 @@ DLLEXPORT void jl_uv_req_set_data(uv_req_t *req, void *data) { req->data = data; } - - + + DLLEXPORT void *jl_uv_req_data(uv_req_t *req) { return req->data; diff --git a/src/jlapi.c b/src/jlapi.c index 2887b0669afac..a3eb39b7e0000 100644 --- a/src/jlapi.c +++ b/src/jlapi.c @@ -102,7 +102,7 @@ DLLEXPORT void *jl_eval_string(char *str) DLLEXPORT jl_value_t *jl_exception_occurred(void) { - return jl_is_null(jl_exception_in_transit) ? NULL : + return jl_is_null(jl_exception_in_transit) ? NULL : jl_exception_in_transit; } diff --git a/src/jltypes.c b/src/jltypes.c index 1a3d0f4866d83..e0e927af9ab35 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -3064,7 +3064,7 @@ void jl_init_types(void) tv); tv = jl_tuple2(tvar("T"), tvar("N")); - jl_array_type = + jl_array_type = jl_new_datatype(jl_symbol("Array"), (jl_datatype_t*) jl_apply_type((jl_value_t*)jl_densearray_type, tv), @@ -3077,12 +3077,12 @@ void jl_init_types(void) (jl_value_t*)jl_apply_type((jl_value_t*)jl_array_type, jl_tuple(2, jl_any_type, jl_box_long(1))); - + jl_array_symbol_type = (jl_value_t*)jl_apply_type((jl_value_t*)jl_array_type, jl_tuple(2, jl_symbol_type, jl_box_long(1))); - + jl_expr_type = jl_new_datatype(jl_symbol("Expr"), jl_any_type, jl_null, diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 88b472015f16a..b06b8407d4746 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -387,7 +387,7 @@ (define (skip-comment port) (define (skip-multiline-comment port count) (let ((c (read-char port))) - (if (eof-object? c) + (if (eof-object? c) (error "incomplete: unterminated multi-line comment #= ... =#") ; NOTE: changing this may affect code in base/client.jl (begin (if (eqv? c #\=) (let ((c (peek-char port))) @@ -668,7 +668,7 @@ ex) (let ((argument (cond ((closing-token? (peek-token s)) - (error (string "missing last argument in \"" + (error (string "missing last argument in \"" (deparse ex) ":\" range expression "))) ((newline? (peek-token s)) (error "line break in \":\" expression")) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index e7854869a384d..9c40f6f83ca58 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -2346,7 +2346,7 @@ (dest (cons (if tail `(return ,e) e) '())) (else (cons e '()))) - + (case (car e) ((call) ;; ensure left-to-right evaluation of arguments (let ((assigned @@ -2382,7 +2382,7 @@ (each-arg (cdr ass) (cdr args) tmp (cons (car args) newa)))))))) - + ((=) (if (or (not (symbol? (cadr e))) (eq? (cadr e) 'true) @@ -2412,7 +2412,7 @@ (= ,LHS ,val) ,val)) dest tail))))) - + ((if) (cond ((or tail (eq? dest #f) (symbol? dest)) (let ((r (to-lff (cadr e) #t #f))) @@ -2426,11 +2426,11 @@ (else (let ((g (gensy))) (cons g (cons `(local! ,g) (to-lff e g #f))))))) - + ((line) (set! *lff-line* (cadr e)) (cons e '())) - + ((trycatch) (cond ((and (eq? dest #t) (not tail)) (let ((g (gensy))) @@ -2442,12 +2442,12 @@ (to-blk (to-lff (cadr e) dest tail))) ,(to-blk (to-lff (caddr e) dest tail))) ())))) - + ((&&) (to-lff (expand-and e) dest tail)) ((|\|\||) (to-lff (expand-or e) dest tail)) - + ((block) (if (length= e 2) (to-lff (cadr e) dest tail) @@ -2469,12 +2469,12 @@ '()) (cons (cons 'block stmts) '())))))) - + ((return) (if (and dest (not tail)) (error "misplaced return statement") (to-lff (cadr e) #t #t))) - + ((_while) (cond ((eq? dest #t) (cons (if tail '(return (null)) '(null)) (to-lff e #f #f))) @@ -2488,7 +2488,7 @@ (if (symbol? dest) (cons `(= ,dest (null)) w) w))))) - + ((break-block) (let ((r (to-lff (caddr e) dest tail))) (if dest @@ -2496,7 +2496,7 @@ (list `(break-block ,(cadr e) ,(to-blk (cdr r))))) (cons `(break-block ,(cadr e) ,(car r)) (cdr r))))) - + ((scope-block) (if (and dest (not tail)) (let* ((g (gensy)) @@ -2511,31 +2511,31 @@ (let ((r (to-lff (cadr e) dest tail))) (cons `(scope-block ,(to-blk r)) '())))) - + ;; move the break to the list of preceding statements. value is ;; null but this will never be observed. ((break) (cons '(null) (list e))) - + ((lambda) (let ((l `(lambda ,(cadr e) ,(to-blk (to-lff (caddr e) #t #t))))) (if (symbol? dest) (cons `(= ,dest ,l) '()) (cons (if tail `(return ,l) l) '())))) - + ((local global) (if dest (error (string "misplaced \"" (car e) "\" declaration"))) (cons (to-blk (to-lff '(null) dest tail)) (list e))) - + ((|::|) (if dest ;; convert to typeassert or decl based on whether it's in ;; value or statement position. (to-lff `(typeassert ,@(cdr e)) dest tail) (to-lff `(decl ,@(cdr e)) dest tail))) - + ((unnecessary-tuple) (if dest (to-lff (cadr e) dest tail) diff --git a/src/julia.h b/src/julia.h index 121bdb9823327..23deca0c62420 100644 --- a/src/julia.h +++ b/src/julia.h @@ -1248,7 +1248,7 @@ DLLEXPORT int jl_spawn(char *name, char **argv, uv_loop_t *loop, uv_process_t *proc, jl_value_t *julia_struct, uv_handle_type stdin_type,uv_pipe_t *stdin_pipe, uv_handle_type stdout_type,uv_pipe_t *stdout_pipe, - uv_handle_type stderr_type,uv_pipe_t *stderr_pipe, + uv_handle_type stderr_type,uv_pipe_t *stderr_pipe, int detach, char **env, char *cwd); DLLEXPORT void jl_run_event_loop(uv_loop_t *loop); DLLEXPORT int jl_run_once(uv_loop_t *loop); diff --git a/src/julia_internal.h b/src/julia_internal.h index 70bf87aee6da0..00c55929e2c6a 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -75,7 +75,7 @@ void jl_add_constructors(jl_datatype_t *t); void jl_compute_field_offsets(jl_datatype_t *st); jl_array_t *jl_new_array_for_deserialization(jl_value_t *atype, uint32_t ndims, size_t *dims, int isunboxed, int elsz); -#ifdef JL_USE_INTEL_JITEVENTS +#ifdef JL_USE_INTEL_JITEVENTS extern char jl_using_intel_jitevents; #endif extern size_t jl_arr_xtralloc_limit; diff --git a/src/match.scm b/src/match.scm index d236902ff8d23..72c6722279921 100644 --- a/src/match.scm +++ b/src/match.scm @@ -41,10 +41,10 @@ (if capt (and (equal? expr (cdr capt)) state) (cons (cons p expr) state)))))) - + ((procedure? p) (and (p expr) state)) - + ((pair? p) (cond ((eq? (car p) '-/) (and (equal? (cadr p) expr) state)) @@ -62,7 +62,7 @@ (equal? (car p) (car expr)) (match-seq (cdr p) (cdr expr) state (length (cdr expr))))))) - + (else (and (equal? p expr) state)))) @@ -98,7 +98,7 @@ (else (or (match-star- p prest expr state var 0 0 L sofar) (match-star- p prest expr state var 1 max L sofar))))) -(define (match-star p prest expr state var min max L) +(define (match-star p prest expr state var min max L) (match-star- p prest expr state var min max L '())) ; match sequences of expressions @@ -232,12 +232,12 @@ (cond ((and (symbol? p) (not (memq p '(_ ...)))) (list p)) - + ((pair? p) (if (eq? (car p) '-/) '() (delete-duplicates (apply append (map patargs- (to-proper (cdr p))))))) - + (else '()))) (define (patargs p) (cons '__ (patargs- p))) diff --git a/src/module.c b/src/module.c index 9bbc245de74a3..13014f8dee7f3 100644 --- a/src/module.c +++ b/src/module.c @@ -385,7 +385,7 @@ DLLEXPORT void jl_set_current_module(jl_value_t *m) DLLEXPORT jl_value_t *jl_module_usings(jl_module_t *m) { jl_array_t *a = jl_alloc_array_1d(jl_array_any_type, 0); - JL_GC_PUSH1(&a); + JL_GC_PUSH1(&a); for(int i=(int)m->usings.len-1; i >= 0; --i) { jl_array_grow_end(a, 1); jl_module_t *imp = (jl_module_t*)m->usings.items[i]; diff --git a/src/profile.c b/src/profile.c index 67ffe99a272b1..cd57ad1fc3787 100644 --- a/src/profile.c +++ b/src/profile.c @@ -70,7 +70,7 @@ DLLEXPORT int jl_profile_start_timer(void) { running = 1; if (hBtThread == 0) { - hBtThread = CreateThread( + hBtThread = CreateThread( NULL, // default security attributes 0, // use default stack size profile_bt, // thread function name @@ -187,7 +187,7 @@ void *mach_profile_listener(void *arg) HANDLE_MACH_ERROR("thread_get_state",ret); // Initialize the unwind context with the suspend thread's state - unw_context_t uc; + unw_context_t uc; memset(&uc,0,sizeof(unw_context_t)); memcpy(&uc,&state,sizeof(x86_thread_state64_t)); @@ -225,7 +225,7 @@ void *mach_profile_listener(void *arg) bt_data_prof[bt_size_cur] = 0; bt_size_cur++; - // We're done! Resume the thread. + // We're done! Resume the thread. ret = thread_resume(main_thread); HANDLE_MACH_ERROR("thread_resume",ret) diff --git a/src/support/MurmurHash3.c b/src/support/MurmurHash3.c index 485cde4040474..6dcde79304394 100644 --- a/src/support/MurmurHash3.c +++ b/src/support/MurmurHash3.c @@ -114,9 +114,9 @@ void MurmurHash3_x86_32 ( const void * key, int len, k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; - + h1 ^= k1; - h1 = ROTL32(h1,13); + h1 = ROTL32(h1,13); h1 = h1*5+0xe6546b64; } @@ -143,7 +143,7 @@ void MurmurHash3_x86_32 ( const void * key, int len, h1 = fmix32(h1); *(uint32_t*)out = h1; -} +} //----------------------------------------------------------------------------- @@ -158,9 +158,9 @@ void MurmurHash3_x86_128 ( const void * key, const int len, uint32_t h3 = seed; uint32_t h4 = seed; - uint32_t c1 = 0x239b961b; + uint32_t c1 = 0x239b961b; uint32_t c2 = 0xab0e9789; - uint32_t c3 = 0x38b34ae5; + uint32_t c3 = 0x38b34ae5; uint32_t c4 = 0xa1e38b93; //---------- diff --git a/src/support/Windows.mk b/src/support/Windows.mk index 9c34e8fff0cdb..2c7909c6e1191 100644 --- a/src/support/Windows.mk +++ b/src/support/Windows.mk @@ -47,6 +47,6 @@ lib$(NAME).lib: $(OBJECTS) .c.obj: $(CC) $(CFLAGS) $< - + # vim: noexpandtab:ts=4:sw=4: diff --git a/src/support/asprintf.c b/src/support/asprintf.c index 10aa692f94ef7..92404d489ebf5 100644 --- a/src/support/asprintf.c +++ b/src/support/asprintf.c @@ -95,7 +95,7 @@ int asprintf(char **str, const char *fmt, ...) { va_list ap; int ret; - + *str = NULL; va_start(ap, fmt); ret = vasprintf(str, fmt, ap); diff --git a/src/support/dtypes.h b/src/support/dtypes.h index 96b8a7aef0c10..66b74fe100a03 100644 --- a/src/support/dtypes.h +++ b/src/support/dtypes.h @@ -21,7 +21,7 @@ #define strtoull _strtoui64 #define strtoll _strtoi64 -#define strcasecmp _stricmp +#define strcasecmp _stricmp #define strncasecmp _strnicmp #define snprintf _snprintf #define stat _stat diff --git a/src/support/ios.c b/src/support/ios.c index e70fe902dec0b..dbab4edbca747 100644 --- a/src/support/ios.c +++ b/src/support/ios.c @@ -249,7 +249,7 @@ static size_t _ios_read(ios_t *s, char *dest, size_t n, int all) while (n > 0) { avail = s->size - s->bpos; - + if (avail > 0) { size_t ncopy = (avail >= n) ? n : avail; memcpy(dest, s->buf + s->bpos, ncopy); @@ -264,14 +264,14 @@ static size_t _ios_read(ios_t *s, char *dest, size_t n, int all) s->_eof = 1; return avail; } - + dest += avail; n -= avail; tot += avail; - + ios_flush(s); s->bpos = s->size = 0; - + s->fpos = -1; if (n > MOST_OF(s->maxsize)) { // doesn't fit comfortably in buffer; go direct diff --git a/src/support/strtod.c b/src/support/strtod.c index 5ea3f5558d319..2d6b1f20a728e 100644 --- a/src/support/strtod.c +++ b/src/support/strtod.c @@ -17,7 +17,7 @@ extern "C" { // Cache locale object static int c_locale_initialized = 0; static locale_t c_locale; - + locale_t get_c_locale() { if(!c_locale_initialized) @@ -27,7 +27,7 @@ locale_t get_c_locale() } return c_locale; } - + double strtod_c(const char *nptr, char **endptr) { return strtod_l(nptr, endptr, get_c_locale()); @@ -40,7 +40,7 @@ float strtof_c(const char *nptr, char **endptr) #else -// This code path should be used for systems that do not support the strtod_l function +// This code path should be used for systems that do not support the strtod_l function // Currently this is MinGW/Windows // The following code is derived from the Python function _PyOS_ascii_strtod @@ -131,12 +131,12 @@ double strtod_c(const char *nptr, char **endptr) the system strtod. This ensures that the result of an underflow has the correct sign. */ p = nptr; - + /* parse leading spaces */ while (isspace((unsigned char)*p)) { p++; } - + /* Process leading sign, if present */ if (*p == '-') { negate = 1; @@ -149,7 +149,7 @@ double strtod_c(const char *nptr, char **endptr) /* This code path is used for hex floats */ if (*p == '0' && (*(p+1) == 'x' || *(p+1) == 'X')) { - digits_pos = p; + digits_pos = p; p += 2; /* Check that what's left begins with a digit or decimal point */ if (!isxdigit(*p) && *p != '.') @@ -186,7 +186,7 @@ double strtod_c(const char *nptr, char **endptr) goto invalid_string; /* For the other cases, we need not convert the decimal point */ - } + } } else { /* Check that what's left begins with a digit or decimal point */ diff --git a/src/support/utils.h b/src/support/utils.h index 99b9d33488ecb..5467e97470fe7 100644 --- a/src/support/utils.h +++ b/src/support/utils.h @@ -85,9 +85,9 @@ STATIC_INLINE u_int64_t ByteSwap64(u_int64_t x) STATIC_INLINE u_int64_t ByteSwap64(u_int64_t x) { - union { + union { u_int64_t ll; - u_int32_t l[2]; + u_int32_t l[2]; } w, r; w.ll = x; r.l[0] = bswap_32 (w.l[1]); diff --git a/src/support/wcwidth.c b/src/support/wcwidth.c index 222f4438db45b..2137eccc1a8c8 100644 --- a/src/support/wcwidth.c +++ b/src/support/wcwidth.c @@ -197,7 +197,7 @@ DLLEXPORT int wcwidth(uint32_t ucs) /* if we arrive here, ucs is not a combining or C0/C1 control character */ - return 1 + + return 1 + (ucs >= 0x1100 && (ucs <= 0x115f || /* Hangul Jamo init. consonants */ ucs == 0x2329 || ucs == 0x232a || diff --git a/src/sys.c b/src/sys.c index 919a1ce7dfc05..f1da68d81af13 100644 --- a/src/sys.c +++ b/src/sys.c @@ -611,7 +611,7 @@ DLLEXPORT const char *jl_pathname_for_handle(uv_lib_t *uv_lib) { if (!uv_lib) return NULL; - + void *handle = uv_lib->handle; #ifdef __APPLE__ for (int32_t i = _dyld_image_count(); i >= 0 ; i--) { diff --git a/src/table.c b/src/table.c index 1e0ecd319eba9..310b2d90f3334 100644 --- a/src/table.c +++ b/src/table.c @@ -66,7 +66,7 @@ static void **jl_table_lookup_bp(jl_array_t **pa, void *key) jl_idtable_rehash(pa, newsz); a = *pa; - tab = (void**)a->data; + tab = (void**)a->data; sz = hash_size(a); maxprobe = max_probe(sz); diff --git a/src/task.c b/src/task.c index 025aa0f0218d2..08264ec8e1241 100644 --- a/src/task.c +++ b/src/task.c @@ -561,7 +561,7 @@ DLLEXPORT size_t rec_backtrace_ctx(ptrint_t *data, size_t maxsize, CONTEXT *Cont jl_in_stackwalk = 0; needsSymRefreshModuleList = 0; } -#if defined(_CPU_X86_64_) +#if defined(_CPU_X86_64_) DWORD MachineType = IMAGE_FILE_MACHINE_AMD64; stk.AddrPC.Offset = Context->Rip; stk.AddrStack.Offset = Context->Rsp; @@ -577,7 +577,7 @@ DLLEXPORT size_t rec_backtrace_ctx(ptrint_t *data, size_t maxsize, CONTEXT *Cont stk.AddrPC.Mode = AddrModeFlat; stk.AddrStack.Mode = AddrModeFlat; stk.AddrFrame.Mode = AddrModeFlat; - + size_t n = 0; intptr_t lastsp = stk.AddrStack.Offset; while (n < maxsize) { @@ -587,7 +587,7 @@ DLLEXPORT size_t rec_backtrace_ctx(ptrint_t *data, size_t maxsize, CONTEXT *Cont jl_in_stackwalk = 0; data[n++] = (intptr_t)stk.AddrPC.Offset; intptr_t sp = (intptr_t)stk.AddrStack.Offset; - if (!result || sp == 0 || + if (!result || sp == 0 || (_stack_grows_up ? sp < lastsp : sp > lastsp) || stk.AddrReturn.Offset == 0) break; @@ -609,7 +609,7 @@ DLLEXPORT size_t rec_backtrace_ctx(ptrint_t *data, size_t maxsize, unw_context_t unw_cursor_t cursor; unw_word_t ip; size_t n=0; - + unw_init_local(&cursor, uc); do { if (n >= maxsize) @@ -630,7 +630,7 @@ size_t rec_backtrace_ctx_dwarf(ptrint_t *data, size_t maxsize, unw_context_t *uc unw_cursor_t cursor; unw_word_t ip; size_t n=0; - + unw_init_local_dwarf(&cursor, uc); do { if (n >= maxsize) diff --git a/src/toplevel.c b/src/toplevel.c index 1551001941751..be577b37a1cdb 100644 --- a/src/toplevel.c +++ b/src/toplevel.c @@ -568,7 +568,7 @@ jl_value_t *jl_load(const char *fname) if (jl_current_module == jl_base_module) { //This deliberatly uses ios, because stdio initialization has been moved to Julia jl_printf(JL_STDOUT, "%s\r\n", fname); -#ifdef _OS_WINDOWS_ +#ifdef _OS_WINDOWS_ uv_run(uv_default_loop(), (uv_run_mode)1); #endif } diff --git a/src/uv_constants.h b/src/uv_constants.h index f66e7798b1f55..21302fbf8e701 100644 --- a/src/uv_constants.h +++ b/src/uv_constants.h @@ -4,7 +4,7 @@ const uv_handle_types = [UV_HANDLE_TYPE_MAP(XX) :UV_FILE] const uv_req_types = [UV_REQ_TYPE_MAP(XX)] const uv_err_vals = [UV_ERRNO_MAP(YY)] -let +let handles = [:UV_UNKNOWN_HANDLE, uv_handle_types, :UV_HANDLE_TYPE_MAX, :UV_RAW_FD, :UV_RAW_HANDLE] reqs = [:UV_UNKNOWN_REQ, uv_req_types, :UV_REQ_TYPE_PRIVATE,:UV_REQ_TYPE_MAX] for i=0:(length(handles)-1) diff --git a/test/arpack.jl b/test/arpack.jl index 274b4b130e90e..b93f116a0b454 100644 --- a/test/arpack.jl +++ b/test/arpack.jl @@ -31,25 +31,25 @@ begin # (d,v) = eigs(a, b, nev=3, tol=1e-8) # not handled yet # @test_approx_eq_eps a*v[:,2] d[2]*b*v[:,2] testtol # @test norm(v) > testtol # eigenvectors cannot be null vectors - + (d,v) = eigs(asym, nev=3) @test_approx_eq asym*v[:,1] d[1]*v[:,1] @test_approx_eq eigs(asym; nev=1, sigma=d[3])[1][1] d[3] @test norm(v) > testtol # eigenvectors cannot be null vectors - + (d,v) = eigs(apd, nev=3) @test_approx_eq apd*v[:,3] d[3]*v[:,3] @test_approx_eq eigs(apd; nev=1, sigma=d[3])[1][1] d[3] - + (d,v) = eigs(apd, bpd, nev=3, tol=1e-8) @test_approx_eq_eps apd*v[:,2] d[2]*bpd*v[:,2] testtol @test norm(v) > testtol # eigenvectors cannot be null vectors - + # test (shift-and-)invert mode (d,v) = eigs(apd, nev=3, sigma=0) @test_approx_eq apd*v[:,3] d[3]*v[:,3] @test norm(v) > testtol # eigenvectors cannot be null vectors - + (d,v) = eigs(apd, bpd, nev=3, sigma=0, tol=1e-8) @test_approx_eq_eps apd*v[:,1] d[1]*bpd*v[:,1] testtol @test norm(v) > testtol # eigenvectors cannot be null vectors @@ -68,7 +68,7 @@ A6965 = [ -1.0 0.0 0.0 0.0 0.0 0.0 7.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 8.0 ]; - + d, = eigs(A6965,which=:SM,nev=2,ncv=4,tol=eps()) @test_approx_eq d[1] 2.5346936860350002 @test_approx_eq real(d[2]) 2.6159972444834976 @@ -76,7 +76,7 @@ d, = eigs(A6965,which=:SM,nev=2,ncv=4,tol=eps()) # Requires ARPACK 3.2 or a patched 3.1.5 #T6965 = [ 0.9 0.05 0.05 -# 0.8 0.1 0.1 +# 0.8 0.1 0.1 # 0.7 0.1 0.2 ] #d,v,nconv = eigs(T6965,nev=1,which=:LM) #@test_approx_eq_eps T6965*v d[1]*v 1e-6 diff --git a/test/bitarray.jl b/test/bitarray.jl index 354ef70d278d1..c306a8f8a538a 100644 --- a/test/bitarray.jl +++ b/test/bitarray.jl @@ -175,7 +175,7 @@ end # multidimensional -rand_m1m2() = rand(1:n1), rand(1:n2) +rand_m1m2() = rand(1:n1), rand(1:n2) b1 = randbool(n1, n2) diff --git a/test/blas.jl b/test/blas.jl index ee014fab4d434..2930fb1b2e90d 100644 --- a/test/blas.jl +++ b/test/blas.jl @@ -6,15 +6,15 @@ for elty in [Float32, Float64, Complex64, Complex128] z4 = zeros(elty, 4) I4 = eye(elty, 4) - I43 = eye(elty, 4, 3) - L4 = tril(ones(elty, (4,4))) + I43 = eye(elty, 4, 3) + L4 = tril(ones(elty, (4,4))) U4 = triu(ones(elty, (4,4))) Z4 = zeros(elty, (4,4)) - elm1 = convert(elty, -1) + elm1 = convert(elty, -1) el2 = convert(elty, 2) v14 = convert(Vector{elty}, [1:4]) - v41 = convert(Vector{elty}, [4:-1:1]) + v41 = convert(Vector{elty}, [4:-1:1]) # dot if elty <: Real @@ -43,15 +43,15 @@ for elty in [Float32, Float64, Complex64, Complex128] @test all(o4cp .== z4) @test all(BLAS.gemv('N', U4, o4) .== v41) @test all(BLAS.gemv('N', U4, o4) .== v41) - + # gemm @test all(BLAS.gemm('N', 'N', I4, I4) .== I4) @test all(BLAS.gemm('N', 'T', I4, I4) .== I4) @test all(BLAS.gemm('T', 'N', I4, I4) .== I4) @test all(BLAS.gemm('T', 'T', I4, I4) .== I4) - @test all(BLAS.gemm('N', 'N', el2, I4, I4) .== el2 * I4) - @test all(BLAS.gemm('N', 'T', el2, I4, I4) .== el2 * I4) - @test all(BLAS.gemm('T', 'N', el2, I4, I4) .== el2 * I4) + @test all(BLAS.gemm('N', 'N', el2, I4, I4) .== el2 * I4) + @test all(BLAS.gemm('N', 'T', el2, I4, I4) .== el2 * I4) + @test all(BLAS.gemm('T', 'N', el2, I4, I4) .== el2 * I4) @test all(LinAlg.BLAS.gemm('T', 'T', el2, I4, I4) .== el2 * I4) I4cp = copy(I4) @test all(BLAS.gemm!('N', 'N', one(elty), I4, I4, elm1, I4cp) .== Z4) @@ -67,7 +67,7 @@ for elty in [Float32, Float64, Complex64, Complex128] @test all(I4cp .== Z4) @test all(BLAS.gemm('N', 'N', I4, U4) .== U4) @test all(BLAS.gemm('N', 'T', I4, U4) .== L4) - + # gemm compared to (sy)(he)rk if iseltype(elm1,Complex) @test all(triu(BLAS.herk('U', 'N', U4)) .== triu(BLAS.gemm('N', 'T', U4, U4))) diff --git a/test/combinatorics.jl b/test/combinatorics.jl index e5ab41021043c..dec88874e2bd7 100644 --- a/test/combinatorics.jl +++ b/test/combinatorics.jl @@ -18,7 +18,7 @@ a = randcycle(10) @test collect(partitions(8, 1)) == Any[[8]] @test collect(partitions(8, 9)) == [] @test collect(partitions([1,2,3])) == Any[Any[[1,2,3]], Any[[1,2],[3]], Any[[1,3],[2]], Any[[1],[2,3]], Any[[1],[2],[3]]] -@test collect(partitions([1,2,3,4],3)) == Any[Any[[1,2],[3],[4]], Any[[1,3],[2],[4]], Any[[1],[2,3],[4]], +@test collect(partitions([1,2,3,4],3)) == Any[Any[[1,2],[3],[4]], Any[[1,3],[2],[4]], Any[[1],[2,3],[4]], Any[[1,4],[2],[3]], Any[[1],[2,4],[3]], Any[[1],[2],[3,4]]] @test collect(partitions([1,2,3,4],1)) == Any[Any[[1, 2, 3, 4]]] @test collect(partitions([1,2,3,4],5)) == [] diff --git a/test/dates/adjusters.jl b/test/dates/adjusters.jl index 4dcdae83eaa52..d6b93c4dcbdf2 100644 --- a/test/dates/adjusters.jl +++ b/test/dates/adjusters.jl @@ -324,14 +324,14 @@ januarymondays2014 = [Dates.Date(2014,1,6),Dates.Date(2014,1,13),Dates.Date(2014 end) == 24 # Thanksgiving: 4th Thursday of November -thanksgiving = x->Dates.dayofweek(x) == Dates.Thu && - Dates.month(x) == Dates.Nov && +thanksgiving = x->Dates.dayofweek(x) == Dates.Thu && + Dates.month(x) == Dates.Nov && Dates.dayofweekofmonth(x) == 4 d = Dates.Date(2014,6,5) @test Dates.tonext(d) do x - thanksgiving(x) + thanksgiving(x) end == Dates.Date(2014,11,27) @test Dates.toprev(d) do x @@ -341,7 +341,7 @@ end == Dates.Date(2013,11,28) # Pittsburgh street cleaning dr = Dates.Date(2014):Dates.Date(2015) @test length(Dates.recur(dr) do x - Dates.dayofweek(x) == Dates.Tue && + Dates.dayofweek(x) == Dates.Tue && Dates.April < Dates.month(x) < Dates.Nov && Dates.dayofweekofmonth(x) == 2 end) == 6 @@ -359,10 +359,10 @@ ischristmas(dt) = Dates.yearmonthday(dt) == christmas(Dates.year(dt)) ismartinlutherking(dt) = Dates.dayofweek(dt) == Dates.Mon && Dates.month(dt) == Dates.Jan && Dates.dayofweekofmonth(dt) == 3 ispresidentsday(dt) = Dates.dayofweek(dt) == Dates.Mon && - Dates.month(dt) == Dates.Feb && Dates.dayofweekofmonth(dt) == 3 + Dates.month(dt) == Dates.Feb && Dates.dayofweekofmonth(dt) == 3 # Last Monday of May -ismemorialday(dt) = Dates.dayofweek(dt) == Dates.Mon && - Dates.month(dt) == Dates.May && +ismemorialday(dt) = Dates.dayofweek(dt) == Dates.Mon && + Dates.month(dt) == Dates.May && Dates.dayofweekofmonth(dt) == Dates.daysofweekinmonth(dt) islaborday(dt) = Dates.dayofweek(dt) == Dates.Mon && Dates.month(dt) == Dates.Sep && Dates.dayofweekofmonth(dt) == 1 @@ -424,12 +424,12 @@ observed = Dates.recur(OBSERVEDHOLIDAYS,Dates.Date(1999):Dates.Date(2000)) # we just look at weekend days and use the "negate" keyword of recur # validate with http://www.workingdays.us/workingdays_holidays_2014.htm @test length(Dates.recur(Dates.Date(2014):Dates.Date(2015);negate=true) do x - OBSERVEDHOLIDAYS(x) || + OBSERVEDHOLIDAYS(x) || Dates.dayofweek(x) > 5 end) == 251 # First day of the next month for each day of 2014 -@test length([Dates.firstdayofmonth(i+Dates.Month(1)) +@test length([Dates.firstdayofmonth(i+Dates.Month(1)) for i in Dates.Date(2014):Dates.Date(2014,12,31)]) == 365 # From those goofy email forwards claiming a "special, lucky month" diff --git a/test/dsp.jl b/test/dsp.jl index 0dcdc44cbb3fe..37a358e5c133f 100644 --- a/test/dsp.jl +++ b/test/dsp.jl @@ -58,7 +58,7 @@ if Base.fftw_vendor() != :mkl Xidct!_1 = copy(true_Xdct_1); idct!(Xidct!_1,1) Xidct_2 = idct(true_Xdct_2,2) Xidct!_2 = copy(true_Xdct_2); idct!(Xidct!_2,2) - + pXdct = plan_dct(X)(X) pXdct! = float(X); plan_dct!(pXdct!)(pXdct!) pXdct_1 = plan_dct(X,1)(X) diff --git a/test/hashing.jl b/test/hashing.jl index eeb936e64f079..d8f86619ceb7a 100644 --- a/test/hashing.jl +++ b/test/hashing.jl @@ -1,5 +1,5 @@ types = Any[ - Bool, + Bool, Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Float32, Float64, Rational{Int8}, Rational{UInt8}, Rational{Int16}, Rational{UInt16}, Rational{Int32}, Rational{UInt32}, Rational{Int64}, Rational{UInt64} diff --git a/test/linalg/triangular.jl b/test/linalg/triangular.jl index ce3eda2670334..6bbafe1740082 100644 --- a/test/linalg/triangular.jl +++ b/test/linalg/triangular.jl @@ -117,7 +117,7 @@ for elty1 in (Float32, Float64, Complex64, Complex128, BigFloat, Int) # Error bounds elty1 != BigFloat && errorbounds(A1, A1\B, B) - + # Determinant @test_approx_eq det(A1) det(lufact(full(A1))) @@ -167,13 +167,13 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) εb = eps(abs(float(one(eltyb)))) ε = max(εa,εb) - debug && println("\ntype of A: ", eltya, " type of b: ", eltyb, "\n") + debug && println("\ntype of A: ", eltya, " type of b: ", eltyb, "\n") debug && println("Solve upper triangular system") Atri = Triangular(lufact(A)[:U], :U) |> t -> eltya <: Complex && eltyb <: Real ? real(t) : t # Here the triangular matrix can't be too badly conditioned b = convert(Matrix{eltyb}, eltya <: Complex ? full(Atri)*ones(n, 2) : full(Atri)*ones(n, 2)) x = full(Atri) \ b - + debug && println("Test error estimates") if eltya != BigFloat && eltyb != BigFloat for i = 1:2 @@ -181,7 +181,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) end end debug && println("Test forward error [JIN 5705] if this is not a BigFloat") - + x = Atri \ b γ = n*ε/(1 - n*ε) if eltya != BigFloat @@ -191,17 +191,17 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) @test norm(x̂[:,i] - x[:,i], Inf)/norm(x̂[:,i], Inf) <= condskeel(bigA, x̂[:,i])*γ/(1 - condskeel(bigA)*γ) end end - + debug && println("Test backward error [JIN 5705]") for i = 1:size(b, 2) @test norm(abs(b[:,i] - Atri*x[:,i]), Inf) <= γ * norm(Atri, Inf) * norm(x[:,i], Inf) end - + debug && println("Solve lower triangular system") Atri = Triangular(lufact(A)[:U], :U) |> t -> eltya <: Complex && eltyb <: Real ? real(t) : t # Here the triangular matrix can't be too badly conditioned b = convert(Matrix{eltyb}, eltya <: Complex ? full(Atri)*ones(n, 2) : full(Atri)*ones(n, 2)) x = full(Atri)\b - + debug && println("Test error estimates") if eltya != BigFloat && eltyb != BigFloat for i = 1:2 @@ -220,7 +220,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) @test norm(x̂[:,i] - x[:,i], Inf)/norm(x̂[:,i], Inf) <= condskeel(bigA, x̂[:,i])*γ/(1 - condskeel(bigA)*γ) end end - + debug && println("Test backward error [JIN 5705]") for i = 1:size(b, 2) @test norm(abs(b[:,i] - Atri*x[:,i]), Inf) <= γ * norm(Atri, Inf) * norm(x[:,i], Inf) diff --git a/test/linalg/tridiag.jl b/test/linalg/tridiag.jl index 8c00a8a7e4581..2edbc7db5acc0 100644 --- a/test/linalg/tridiag.jl +++ b/test/linalg/tridiag.jl @@ -30,7 +30,7 @@ for relty in (Float32, Float64), elty in (relty, )#XXX Complex{relty}) doesn't w A = SymTridiagonal(a, b) fA = (elty <: Complex ? complex128:float64)(full(A)) - + debug && println("Idempotent tests") for func in (conj, transpose, ctranspose) @test func(func(A)) == A diff --git a/test/linalg1.jl b/test/linalg1.jl index 04bc6751a8176..31057b0d3ca93 100644 --- a/test/linalg1.jl +++ b/test/linalg1.jl @@ -28,7 +28,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) asym = a'+a # symmetric indefinite apd = a'*a # symmetric positive-definite ε = εa = eps(abs(float(one(eltya)))) - + for eltyb in (Float32, Float64, Complex64, Complex128, Int) b = eltyb == Int ? rand(1:5, n, 2) : convert(Matrix{eltyb}, eltyb <: Complex ? complex(breal, bimg) : breal) εb = eps(abs(float(one(eltyb)))) @@ -37,7 +37,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) debug && println("\ntype of a: ", eltya, " type of b: ", eltyb, "\n") debug && println("(Automatic) upper Cholesky factor") - + capd = factorize(apd) r = capd[:U] κ = cond(apd, 1) #condition number @@ -252,7 +252,7 @@ debug && println("Matrix square root") debug && println("Lyapunov/Sylvester") if eltya != BigFloat - let + let x = lyap(a, a2) @test_approx_eq -a2 a*x + x*a' x2 = sylvester(a[1:3, 1:3], a[4:n, 4:n], a2[1:3,4:n]) diff --git a/test/linalg2.jl b/test/linalg2.jl index 5863cf85ad9c1..f9cff896fa847 100644 --- a/test/linalg2.jl +++ b/test/linalg2.jl @@ -32,7 +32,7 @@ for elty in (Float32, Float64, Complex64, Complex128, Int) U = rand(1:100, n, 2) V = rand(1:100, 2, n) C = rand(1:100, 2, 2) - else + else d = convert(Vector{elty}, d) dl = convert(Vector{elty}, dl) du = convert(Vector{elty}, du) @@ -110,7 +110,7 @@ for elty in (Float32, Float64, Complex64, Complex128, Int) # axiomatic definition of determinants. # If all axioms are satisfied and all the composition rules work, # all determinants will be correct except for floating point errors. - + # The determinant of the identity matrix should always be 1. for i = 1:10 A = eye(elty, i) @@ -152,7 +152,7 @@ for elty in (Float32, Float64, Complex64, Complex128) @test_approx_eq tril(LinAlg.BLAS.syr2k('L','N',U,V)) tril(U*V.' + V*U.') @test_approx_eq triu(LinAlg.BLAS.syr2k('U','N',U,V)) triu(U*V.' + V*U.') @test_approx_eq tril(LinAlg.BLAS.syr2k('L','T',U,V)) tril(U.'*V + V.'*U) - @test_approx_eq triu(LinAlg.BLAS.syr2k('U','T',U,V)) triu(U.'*V + V.'*U) + @test_approx_eq triu(LinAlg.BLAS.syr2k('U','T',U,V)) triu(U.'*V + V.'*U) end for elty in (Complex64, Complex128) @@ -167,7 +167,7 @@ for elty in (Complex64, Complex128) @test_approx_eq tril(LinAlg.BLAS.her2k('L','N',U,V)) tril(U*V' + V*U') @test_approx_eq triu(LinAlg.BLAS.her2k('U','N',U,V)) triu(U*V' + V*U') @test_approx_eq tril(LinAlg.BLAS.her2k('L','C',U,V)) tril(U'*V + V'*U) - @test_approx_eq triu(LinAlg.BLAS.her2k('U','C',U,V)) triu(U'*V + V'*U) + @test_approx_eq triu(LinAlg.BLAS.her2k('U','C',U,V)) triu(U'*V + V'*U) end # Test givens rotations @@ -218,9 +218,9 @@ for elty in (Float32, Float64, Complex{Float32}, Complex{Float64}) @test_approx_eq FJulia.ipiv FLAPACK[2] @test_approx_eq FJulia.info FLAPACK[3] end - + ## QR - FJulia = invoke(qrfact!, (AbstractMatrix,), copy(A)) + FJulia = invoke(qrfact!, (AbstractMatrix,), copy(A)) FLAPACK = Base.LinAlg.LAPACK.geqrf!(copy(A)) @test_approx_eq FJulia.factors FLAPACK[1] @test_approx_eq FJulia.τ FLAPACK[2] @@ -292,17 +292,17 @@ for elty in (Float32, Float64, BigFloat, Complex{Float32}, Complex{Float64}, Com norm(x[1:1]) === norm(x[1], 2) norm(x[1:1]) === norm(x[1], Inf) - for i = 1:10 - x = elty <: Integer ? convert(Vector{elty}, rand(1:10, nnorm)) : - elty <: Complex ? convert(Vector{elty}, complex(randn(nnorm), randn(nnorm))) : + for i = 1:10 + x = elty <: Integer ? convert(Vector{elty}, rand(1:10, nnorm)) : + elty <: Complex ? convert(Vector{elty}, complex(randn(nnorm), randn(nnorm))) : convert(Vector{elty}, randn(nnorm)) xs = sub(x,1:2:nnorm) - y = elty <: Integer ? convert(Vector{elty}, rand(1:10, nnorm)) : - elty <: Complex ? convert(Vector{elty}, complex(randn(nnorm), randn(nnorm))) : - convert(Vector{elty}, randn(nnorm)) + y = elty <: Integer ? convert(Vector{elty}, rand(1:10, nnorm)) : + elty <: Complex ? convert(Vector{elty}, complex(randn(nnorm), randn(nnorm))) : + convert(Vector{elty}, randn(nnorm)) ys = sub(y,1:2:nnorm) - α = elty <: Integer ? randn() : - elty <: Complex ? convert(elty, complex(randn(),randn())) : + α = elty <: Integer ? randn() : + elty <: Complex ? convert(elty, complex(randn(),randn())) : convert(elty, randn()) # Absolute homogeneity @test_approx_eq norm(α*x,-Inf) abs(α)*norm(x,-Inf) @@ -311,7 +311,7 @@ for elty in (Float32, Float64, BigFloat, Complex{Float32}, Complex{Float64}, Com @test_approx_eq norm(α*x) abs(α)*norm(x) # two is default @test_approx_eq norm(α*x,3) abs(α)*norm(x,3) @test_approx_eq norm(α*x,Inf) abs(α)*norm(x,Inf) - + @test_approx_eq norm(α*xs,-Inf) abs(α)*norm(xs,-Inf) @test_approx_eq norm(α*xs,-1) abs(α)*norm(xs,-1) @test_approx_eq norm(α*xs,1) abs(α)*norm(xs,1) @@ -324,7 +324,7 @@ for elty in (Float32, Float64, BigFloat, Complex{Float32}, Complex{Float64}, Com @test norm(x + y) <= norm(x) + norm(y) # two is default @test norm(x + y,3) <= norm(x,3) + norm(y,3) @test norm(x + y,Inf) <= norm(x,Inf) + norm(y,Inf) - + @test norm(xs + ys,1) <= norm(xs,1) + norm(ys,1) @test norm(xs + ys) <= norm(xs) + norm(ys) # two is default @test norm(xs + ys,3) <= norm(xs,3) + norm(ys,3) @@ -350,23 +350,23 @@ for elty in (Float32, Float64, BigFloat, Complex{Float32}, Complex{Float64}, Com @test_approx_eq norm(As, Inf) 5 for i = 1:10 - A = elty <: Integer ? convert(Matrix{elty}, rand(1:10, mmat, nmat)) : - elty <: Complex ? convert(Matrix{elty}, complex(randn(mmat, nmat), randn(mmat, nmat))) : + A = elty <: Integer ? convert(Matrix{elty}, rand(1:10, mmat, nmat)) : + elty <: Complex ? convert(Matrix{elty}, complex(randn(mmat, nmat), randn(mmat, nmat))) : convert(Matrix{elty}, randn(mmat, nmat)) As = sub(A,1:nmat,1:nmat) - B = elty <: Integer ? convert(Matrix{elty}, rand(1:10, mmat, nmat)) : - elty <: Complex ? convert(Matrix{elty}, complex(randn(mmat, nmat), randn(mmat, nmat))) : - convert(Matrix{elty}, randn(mmat, nmat)) + B = elty <: Integer ? convert(Matrix{elty}, rand(1:10, mmat, nmat)) : + elty <: Complex ? convert(Matrix{elty}, complex(randn(mmat, nmat), randn(mmat, nmat))) : + convert(Matrix{elty}, randn(mmat, nmat)) Bs = sub(B,1:nmat,1:nmat) α = elty <: Integer ? randn() : - elty <: Complex ? convert(elty, complex(randn(),randn())) : + elty <: Complex ? convert(elty, complex(randn(),randn())) : convert(elty, randn()) # Absolute homogeneity @test_approx_eq norm(α*A,1) abs(α)*norm(A,1) elty <: Union(BigFloat,Complex{BigFloat},BigInt) || @test_approx_eq norm(α*A) abs(α)*norm(A) # two is default @test_approx_eq norm(α*A,Inf) abs(α)*norm(A,Inf) - + @test_approx_eq norm(α*As,1) abs(α)*norm(As,1) elty <: Union(BigFloat,Complex{BigFloat},BigInt) || @test_approx_eq norm(α*As) abs(α)*norm(As) # two is default @test_approx_eq norm(α*As,Inf) abs(α)*norm(As,Inf) @@ -375,7 +375,7 @@ for elty in (Float32, Float64, BigFloat, Complex{Float32}, Complex{Float64}, Com @test norm(A + B,1) <= norm(A,1) + norm(B,1) elty <: Union(BigFloat,Complex{BigFloat},BigInt) || @test norm(A + B) <= norm(A) + norm(B) # two is default @test norm(A + B,Inf) <= norm(A,Inf) + norm(B,Inf) - + @test norm(As + Bs,1) <= norm(As,1) + norm(Bs,1) elty <: Union(BigFloat,Complex{BigFloat},BigInt) || @test norm(As + Bs) <= norm(As) + norm(Bs) # two is default @test norm(As + Bs,Inf) <= norm(As,Inf) + norm(Bs,Inf) @@ -458,16 +458,16 @@ let a = [1, 2, 3] b = [4, 5, 6] @test kron(eye(2),eye(2)) == eye(4) - @test kron(a,b) == [4,5,6,8,10,12,12,15,18] - @test kron(a',b') == [4 5 6 8 10 12 12 15 18] - @test kron(a,b') == [4 5 6; 8 10 12; 12 15 18] - @test kron(a',b) == [4 8 12; 5 10 15; 6 12 18] - @test kron(a,eye(2)) == [1 0; 0 1; 2 0; 0 2; 3 0; 0 3] - @test kron(eye(2),a) == [ 1 0; 2 0; 3 0; 0 1; 0 2; 0 3] - @test kron(eye(2),2) == 2*eye(2) - @test kron(3,eye(3)) == 3*eye(3) - @test kron(a,2) == [2, 4, 6] - @test kron(b',2) == [8 10 12] + @test kron(a,b) == [4,5,6,8,10,12,12,15,18] + @test kron(a',b') == [4 5 6 8 10 12 12 15 18] + @test kron(a,b') == [4 5 6; 8 10 12; 12 15 18] + @test kron(a',b) == [4 8 12; 5 10 15; 6 12 18] + @test kron(a,eye(2)) == [1 0; 0 1; 2 0; 0 2; 3 0; 0 3] + @test kron(eye(2),a) == [ 1 0; 2 0; 3 0; 0 1; 0 2; 0 3] + @test kron(eye(2),2) == 2*eye(2) + @test kron(3,eye(3)) == 3*eye(3) + @test kron(a,2) == [2, 4, 6] + @test kron(b',2) == [8 10 12] end # issue #4796 diff --git a/test/linalg4.jl b/test/linalg4.jl index e71059f7e3977..c13e3693d55a3 100644 --- a/test/linalg4.jl +++ b/test/linalg4.jl @@ -93,7 +93,7 @@ for relty in (Float32, Float64, BigFloat), elty in (relty, Complex{relty}) end debug && println("Binary operations") - for isupper2 in (true, false) + for isupper2 in (true, false) dv = convert(Vector{elty}, randn(n)) ev = convert(Vector{elty}, randn(n-1)) T2 = Bidiagonal(dv, ev, isupper2) diff --git a/test/math.jl b/test/math.jl index 286190fdae4dd..c97a73213d9f9 100644 --- a/test/math.jl +++ b/test/math.jl @@ -11,7 +11,7 @@ for T = (Float32,Float64,Rational{Int}) @test_approx_eq_eps sind(convert(T,x))::fT convert(fT,sin(pi/180*x)) eps(deg2rad(convert(fT,x))) @test_approx_eq_eps cosd(convert(T,x))::fT convert(fT,cos(pi/180*x)) eps(deg2rad(convert(fT,x))) end - + @test sind(convert(T,0.0))::fT === zero(fT) @test sind(convert(T,180.0))::fT === zero(fT) @test sind(convert(T,360.0))::fT === zero(fT) diff --git a/test/netload/memtest.jl b/test/netload/memtest.jl index dbef7f2ea7171..785ee788abb5d 100644 --- a/test/netload/memtest.jl +++ b/test/netload/memtest.jl @@ -1,22 +1,22 @@ immutable RUsage - ru_utime_sec::Clong # user CPU time used - ru_utime_usec::Clong # user CPU time used - ru_stime_sec::Clong # system CPU time used - ru_stime_usec::Clong # system CPU time used - ru_maxrss::Clong # maximum resident set size - ru_ixrss::Clong # integral shared memory size - ru_idrss::Clong # integral unshared data size - ru_isrss::Clong # integral unshared stack size - ru_minflt::Clong # page reclaims (soft page faults) - ru_majflt::Clong # page faults (hard page faults) - ru_nswap::Clong # swaps - ru_inblock::Clong # block input operations - ru_oublock::Clong # block output operations - ru_msgsnd::Clong # IPC messages sent - ru_msgrcv::Clong # IPC messages received - ru_nsignals::Clong # signals received - ru_nvcsw::Clong # voluntary context switches - ru_nivcsw::Clong # involuntary context switches + ru_utime_sec::Clong # user CPU time used + ru_utime_usec::Clong # user CPU time used + ru_stime_sec::Clong # system CPU time used + ru_stime_usec::Clong # system CPU time used + ru_maxrss::Clong # maximum resident set size + ru_ixrss::Clong # integral shared memory size + ru_idrss::Clong # integral unshared data size + ru_isrss::Clong # integral unshared stack size + ru_minflt::Clong # page reclaims (soft page faults) + ru_majflt::Clong # page faults (hard page faults) + ru_nswap::Clong # swaps + ru_inblock::Clong # block input operations + ru_oublock::Clong # block output operations + ru_msgsnd::Clong # IPC messages sent + ru_msgrcv::Clong # IPC messages received + ru_nsignals::Clong # signals received + ru_nvcsw::Clong # voluntary context switches + ru_nivcsw::Clong # involuntary context switches end function get_vmsize() @@ -48,8 +48,8 @@ function mtest_create_strings() string("$i") end gc() -end - +end + function mtest_remotecall_fetch() for i in 1:10^5 remotecall_fetch(1, myid) @@ -60,4 +60,4 @@ end run_mtest("create_strings", () -> mtest_create_strings()) run_mtest("remotecall_fetch", () -> mtest_remotecall_fetch()) - + diff --git a/test/netload/nettest.jl b/test/netload/nettest.jl index c370d07c8de0d..c59534a7c3fbc 100644 --- a/test/netload/nettest.jl +++ b/test/netload/nettest.jl @@ -113,7 +113,7 @@ test_send(9) bsent = 0 bread = 0 - + @sync begin # Create an asynchronous task that can modify bread properly recv_task = @task begin @@ -125,7 +125,7 @@ test_send(9) end Base.sync_add(recv_task) Base.enq_work(recv_task) - + send_task = @task begin # write in chunks of xfer_block data = fill!(zeros(UInt8, xfer_block), int8(65)) diff --git a/test/parallel.jl b/test/parallel.jl index 7626bb5154583..c51b76b507f79 100644 --- a/test/parallel.jl +++ b/test/parallel.jl @@ -153,7 +153,7 @@ end et=toq() # assuming that 0.5 seconds is a good enough buffer on a typical modern CPU -try +try @test (et >= 1.0) && (et <= 1.5) @test !isready(rr3) catch diff --git a/test/perf/README.md b/test/perf/README.md index 537ccd8fda40f..ee57434c59fe3 100644 --- a/test/perf/README.md +++ b/test/perf/README.md @@ -13,7 +13,7 @@ the sub-directories and display the test name with the minimum, maximum, mean and standard deviation of the wall-time of five repeated test runs in micro seconds. -Calling `make codespeed` is for generating the results displayed on +Calling `make codespeed` is for generating the results displayed on [http://speed.julialang.org/](http://speed.julialang.org/), probably not what you want. @@ -33,11 +33,11 @@ suites: - `cat`: Performance tests for concatenation of vectors and matrices. - `kernel`: Performance tests used to track real-world code examples that previously ran slowly. -- `shootout` Tracks the performance of tests taken from the +- `shootout` Tracks the performance of tests taken from the [Debian shootout](http://shootout.alioth.debian.org/) performance tests. - `sort`: Performance tests of sorting algorithms. -- `spell` Performance tests of +- `spell` Performance tests of [Peter Norvig's spelling corrector](http://norvig.com/spell-correct.html). - `sparse`: Performance tests of sparse matrix operations. diff --git a/test/perf/cat/perf.jl b/test/perf/cat/perf.jl index e3475f65d29e0..2761c6e25b62c 100644 --- a/test/perf/cat/perf.jl +++ b/test/perf/cat/perf.jl @@ -89,6 +89,6 @@ testdata = [(cat2d_perf, "hvcat", "horizontal/vertical matrix concatenat (vcat_perf, "vcat", "vertical matrix concatenation", problemsizes), (vcat_perf2, "vcat_setind", "vertical matrix concatenation using setindex", problemsizes), (catnd_perf, "catnd", "N-dimensional matrix concatenation", problemsizes), - (catnd_perf2, "catnd_setind", "N-dimensional matrix concatenation using setindex", problemsizes)] + (catnd_perf2, "catnd_setind", "N-dimensional matrix concatenation using setindex", problemsizes)] include("../perfgeneric.jl") diff --git a/test/perf/kernel/actor_centrality.jl b/test/perf/kernel/actor_centrality.jl index 98c9a6e2ffa41..3876c44cf6008 100644 --- a/test/perf/kernel/actor_centrality.jl +++ b/test/perf/kernel/actor_centrality.jl @@ -40,7 +40,7 @@ function read_graph() actors = Set() open(joinpath(JULIA_HOME,"..","..","test","perf","kernel","imdb-1.tsv"), "r") do io - while !eof(io) + while !eof(io) k = split(strip(readline(io)), "\t") actor, movie = k[1], join(k[2:3], "_") ac, mn = get(G, actor), get(G, movie) @@ -62,7 +62,7 @@ function actor_centrality() end vals = sort!([(v,k) for (k,v) in d]) - #for i=1:20 + #for i=1:20 # print("$i: ", vals[i], "\n") #end diff --git a/test/perf/kernel/bench_eu.m b/test/perf/kernel/bench_eu.m index abefaf7df3cc0..5b4677f50efc8 100644 --- a/test/perf/kernel/bench_eu.m +++ b/test/perf/kernel/bench_eu.m @@ -13,4 +13,4 @@ rnd = randn(numPaths,1); S = S .* exp((r-0.5*sigma.^2)*dt + sigma*sqrt(dt)*rnd); end -V = mean( exp(-r*T)*max(K-S,0) ) \ No newline at end of file +V = mean( exp(-r*T)*max(K-S,0) ) diff --git a/test/perf/kernel/getdivgrad.jl b/test/perf/kernel/getdivgrad.jl index 953042ff96106..2cf353a79f82a 100644 --- a/test/perf/kernel/getdivgrad.jl +++ b/test/perf/kernel/getdivgrad.jl @@ -26,7 +26,7 @@ function spdiags(B,d,m,n) d = d[:] p = length(d) - + len = zeros(p+1,1) for k = 1:p len[k+1] = int(len[k]+length(max(1,1-d[k]):min(m,n-d[k]))) @@ -37,10 +37,10 @@ function spdiags(B,d,m,n) i = max(1,1-d[k]):min(m,n-d[k]) a[(int(len[k])+1):int(len[k+1]),:] = [i i+d[k] B[i+(m>=n)*d[k],k]] end - + A = sparse(int(a[:,1]),int(a[:,2]),a[:,3],m,n); - + return A - + end diff --git a/test/perf/kernel/gk.m b/test/perf/kernel/gk.m index 60c77088503fa..24aa2e1fee206 100644 --- a/test/perf/kernel/gk.m +++ b/test/perf/kernel/gk.m @@ -160,4 +160,4 @@ display('Skew symmetric MATRIX CREATED'); end -%} \ No newline at end of file +%} diff --git a/test/perf/kernel/go_benchmark.c b/test/perf/kernel/go_benchmark.c index 9a0dcdb901099..0678a62905171 100644 --- a/test/perf/kernel/go_benchmark.c +++ b/test/perf/kernel/go_benchmark.c @@ -106,7 +106,7 @@ static int legal_move(int i, int j, int color) { int other = OTHER_COLOR(color); - + /* Pass is always legal. */ if (pass_move(i, j)) return 1; @@ -217,7 +217,7 @@ same_string(int pos1, int pos2) return 1; pos = next_stone[pos]; } while (pos != pos1); - + return 0; } @@ -307,7 +307,7 @@ play_move(int i, int j, int color) if (on_board(ai, aj) && get_board(ai, aj) == EMPTY) break; } - + if (!has_additional_liberty(i, j, ai, aj)) { ko_i = ai; ko_j = aj; @@ -410,7 +410,7 @@ compute_final_status(void) for (pos = 0; pos < board_size * board_size; pos++) final_status[pos] = UNKNOWN; - + for (i = 0; i < board_size; i++) for (j = 0; j < board_size; j++) if (get_board(i, j) == EMPTY) diff --git a/test/perf/kernel/go_benchmark.jl b/test/perf/kernel/go_benchmark.jl index 7d54ee3dffe35..f65068d418076 100644 --- a/test/perf/kernel/go_benchmark.jl +++ b/test/perf/kernel/go_benchmark.jl @@ -43,22 +43,22 @@ neighbor(i::Int, j::Int, k::Int) = (i + deltai[k], j + deltaj[k]) type Board size::Int komi::Float64 - + # Board represented by a 1D array. The first board_size*board_size # elements are used. Vertices are indexed row by row, starting with 0 # in the upper left corner. board::Matrix{Int} - + # Stones are linked together in a circular list for each string. next_stone::Matrix{Int} - + # Storage for final status computations. final_status::Matrix{Int} - + # Point which would be an illegal ko recapture. ko_i::Int ko_j::Int - + # xor-shift random number generator. rand::XorRand @@ -350,28 +350,28 @@ end # Compute final status. This function is only valid to call in a # position where generate_move() would return pass for at least one # color. -# +# # Due to the nature of the move generation algorithm, the final # status of stones can be determined by a very simple algorithm: -# +# # 1. Stones with two or more liberties are alive with territory. # 2. Stones in atari are dead. -# +# # Moreover alive stones are unconditionally alive even if the # opponent is allowed an arbitrary number of consecutive moves. # Similarly dead stones cannot be brought alive even by an arbitrary # number of consecutive moves. -# +# # Seki is not an option. The move generation algorithm would never # leave a seki on the board. -# +# # Comment: This algorithm doesn't work properly if the game ends with # an unfilled ko. If three passes are required for game end, # that will not happen. -# +# function compute_final_status(board::Board) board.final_status[:] = UNKNOWN - + for i = 1:board.size, j = 1:board.size if board[i, j] == EMPTY for k = 1:4 @@ -384,7 +384,7 @@ function compute_final_status(board::Board) # never leave two adjacent empty vertices. Check the number # of liberties to decide its status, unless it's known # already. - # + # # If we should be called in a non-final position, just make # sure we don't call set_final_status_string() on an empty # vertex. diff --git a/test/perf/kernel/json.jl b/test/perf/kernel/json.jl index a7844b0d6a80f..4367c5c153b73 100644 --- a/test/perf/kernel/json.jl +++ b/test/perf/kernel/json.jl @@ -7,7 +7,7 @@ function parse_json(strng::AbstractString) len = length(strng) # AbstractString delimiters and escape characters are identified beforehand to improve speed # esc = regexp(str, "[\"\\\\]"); index_esc = 1; len_esc = length(esc); #TODO Enable for speed - + function parse_object() parse_char('{') object = Dict{AbstractString, Any}() @@ -29,7 +29,7 @@ function parse_json(strng::AbstractString) parse_char('}') return object end - + function parse_array() parse_char('[') object = Set() @@ -46,7 +46,7 @@ function parse_json(strng::AbstractString) parse_char(']') return object end - + function parse_char(c::Char) skip_whitespace() if pos > len || strng[pos] != c @@ -56,22 +56,22 @@ function parse_json(strng::AbstractString) skip_whitespace() end end - + function next_char() skip_whitespace() if pos > len c = '\0' else c = strng[pos] - end + end end - + function skip_whitespace() while pos <= len && isspace(strng[pos]) pos = pos + 1 end end - + function parse_string() if strng[pos] != '"' error("AbstractString starting with quotation expected at position $pos") @@ -80,7 +80,7 @@ function parse_json(strng::AbstractString) end str = "" while pos <= len - # while index_esc <= len_esc && esc(index_esc) < pos + # while index_esc <= len_esc && esc(index_esc) < pos # index_esc = index_esc + 1 # end # if index_esc > len_esc @@ -92,7 +92,7 @@ function parse_json(strng::AbstractString) # pos = esc(index_esc) # end nc = strng[pos] - if nc == '"' + if nc == '"' pos = pos + 1 return string(str) elseif nc == '\\' @@ -121,7 +121,7 @@ function parse_json(strng::AbstractString) end error("End of file while expecting end of string") end - + function parse_number() num_regex = r"^[\w]?[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?[\w]?" m = match(num_regex, strng[pos:min(len,pos+20)]) @@ -132,7 +132,7 @@ function parse_json(strng::AbstractString) pos = pos + delta -1 return float(m.match) end - + function parse_value() nc = strng[pos] if nc == '"' @@ -168,7 +168,7 @@ function parse_json(strng::AbstractString) end error("Value expected at position $pos") end - + if pos <= len nc = next_char() if nc == '{' diff --git a/test/perf/kernel/laplace.jl b/test/perf/kernel/laplace.jl index 850ddedfa9b3e..711698f0fa9e3 100644 --- a/test/perf/kernel/laplace.jl +++ b/test/perf/kernel/laplace.jl @@ -2,19 +2,19 @@ function laplace_iter_devec(u, dx2, dy2, Niter, N) uout = copy(u) for iter = 1:Niter for i = 2:N-1 - for j = 2:N-1 + for j = 2:N-1 uout[i,j] = ( (u[i-1,j]+u[i+1,j])*dy2 + (u[i,j-1]+u[i,j+1])*dx2 ) * (1./(2*(dx2+dy2))) - end + end end u, uout = uout, u end return u -end +end function laplace_devec() N = 150 - u = zeros(N, N) - u[1,:] = 1 + u = zeros(N, N) + u[1,:] = 1 Niter = 2^10 dx2 = dy2 = 0.1*0.1 u = laplace_iter_devec(u, dx2, dy2, Niter, N) @@ -28,10 +28,10 @@ function laplace_iter_vec(u, dx2, dy2, Niter, N) end function laplace_vec() - N = 150 - u = zeros(N,N) - u[1,:] = 1 - Niter = 2^10 + N = 150 + u = zeros(N,N) + u[1,:] = 1 + Niter = 2^10 dx2 = dy2 = 0.1*0.1 u = laplace_iter_vec(u, dx2, dy2, Niter, N) end diff --git a/test/perf/kernel/laplace/c_laplace.c b/test/perf/kernel/laplace/c_laplace.c index b01c113d2a496..63f5d1506aa43 100644 --- a/test/perf/kernel/laplace/c_laplace.c +++ b/test/perf/kernel/laplace/c_laplace.c @@ -22,7 +22,7 @@ main() { for(i=0; i= i.lambda @@ -63,14 +63,14 @@ function intersect(s::Sphere, i::Hit, ray::Ray) return Hit(l, unitize(n)) end end - + immutable Group <: Scene bound::Sphere objs::Array{Scene} end - + Group(b::Sphere) = Group(b, Scene[]) - + function intersect(g::Group, i::Hit, ray::Ray) l = ray_sphere(g.bound, ray) if l >= i.lambda @@ -82,7 +82,7 @@ function intersect(g::Group, i::Hit, ray::Ray) return i end end - + function ray_trace(light::Vec, ray::Ray, scene::Scene) i = intersect(scene, Hit(Inf, Vec(0.,0.,0.)), ray) if i.lambda == Inf @@ -97,7 +97,7 @@ function ray_trace(light::Vec, ray::Ray, scene::Scene) si = intersect(scene, Hit(Inf, Vec(0.,0.,0.)), sray) return si.lambda == Inf ? -g : 0 end - + function create(level, c::Vec, r) sphere = Sphere(c, r) if level == 1 @@ -114,8 +114,8 @@ function create(level, c::Vec, r) end return group end - - + + function Raytracer(levels, n, ss) scene = create(levels, Vec(0., -1., 0.), 1.) light = unitize(Vec(-1., -3., 2.)) diff --git a/test/perf/kernel/simplex.jl b/test/perf/kernel/simplex.jl index f5a965e02b648..eca9079723570 100644 --- a/test/perf/kernel/simplex.jl +++ b/test/perf/kernel/simplex.jl @@ -35,7 +35,7 @@ function doTwoPassRatioTest() for i in 1:n thisState = varstate[i] pivotElt = tabrow[i] - if (thisState == AtLower && pivotElt > pivotTol) || (thisState == AtUpper && pivotElt < -pivotTol) + if (thisState == AtLower && pivotElt > pivotTol) || (thisState == AtUpper && pivotElt < -pivotTol) candidates[ncandidates += 1] = i ratio = 0. if (pivotElt < 0.) diff --git a/test/perf/kernel/stockcorr.m b/test/perf/kernel/stockcorr.m index 6df4fa9da6245..e5df602c570c2 100644 --- a/test/perf/kernel/stockcorr.m +++ b/test/perf/kernel/stockcorr.m @@ -33,4 +33,4 @@ %% Plot the distribution of final prices % Comment this section out if doing timings % subplot(1,2,1);hist(SimulPriceA(end,:),100); -% subplot(1,2,2);hist(SimulPriceB(end,:),100); \ No newline at end of file +% subplot(1,2,2);hist(SimulPriceB(end,:),100); diff --git a/test/perf/micro/Makefile b/test/perf/micro/Makefile index 53da2b4443951..d68b4f83c2d5b 100644 --- a/test/perf/micro/Makefile +++ b/test/perf/micro/Makefile @@ -52,7 +52,7 @@ bin/perf%: perf.c perf.h $(CC) -std=c99 -O$* $< -o $@ -I$(DSFMTDIR) -L$(BLASDIR) $(LIBBLAS) -L$(LIBMDIR) $(LIBM) $(CFLAGS) -lpthread bin/fperf%: perf.f90 - mkdir -p mods/$@ #Modules for each binary go in separate directories + mkdir -p mods/$@ #Modules for each binary go in separate directories $(FC) $(FFLAGS) -Jmods/$@ -O$* $< -o $@ -L$(BLASDIR) $(LIBBLAS) -L$(LIBMDIR) $(LIBM) -lpthread benchmarks/c.csv: \ diff --git a/test/perf/micro/java/src/main/java/PerfBLAS.java b/test/perf/micro/java/src/main/java/PerfBLAS.java index 01aed2e87a581..390c407b67606 100644 --- a/test/perf/micro/java/src/main/java/PerfBLAS.java +++ b/test/perf/micro/java/src/main/java/PerfBLAS.java @@ -9,7 +9,7 @@ public class PerfBLAS { private static final int NITER = 5; private static Random rand = new Random(0); - + public static void main(String[] args) { long t, tmin; @@ -48,7 +48,7 @@ public static void main(String[] args) { t = System.nanoTime()-t; if (t < tmin) tmin = t; } - assert(mandel_sum == 14720) : "value was "+mandel_sum; + assert(mandel_sum == 14720) : "value was "+mandel_sum; print_perf("mandel", tmin); // sort @@ -77,7 +77,7 @@ public static void main(String[] args) { } assert(Math.abs(pi-1.644834071848065) < 1e-12); print_perf("pi_sum", tmin); - + // rand mat stat double[] r; tmin = Long.MAX_VALUE; @@ -88,7 +88,7 @@ public static void main(String[] args) { if (t < tmin) tmin = t; } print_perf("rand_mat_stat", tmin); - + tmin = Long.MAX_VALUE; for (int i=0; i vElements = v.elementsAsList(); List wElements = w.elementsAsList(); - + return new double[]{stdev(vElements)/mean(vElements),stdev(wElements)/mean(wElements)}; } - + public static double stdev(List elements) { double m = mean(elements); double total = 0; for(Double d:elements) { double dif = (d-m); - total += dif*dif; + total += dif*dif; } return Math.sqrt(total/(elements.size()-1)); } - + public static double mean(List elements) { double total = 0; for(Double d:elements) { @@ -202,7 +202,7 @@ public static double mean(List elements) { } return total/elements.size(); } - + private static void quicksort(double[] a, int lo, int hi) { int i = lo; int j = hi; @@ -254,13 +254,13 @@ private static int mandel(double re, double im) { n -= 1; break; } - + // z = z*z + c z = Complex.add(Complex.mul(z, z), c) } return n+1; } - + private static int mandelperf() { int mandel_sum = 0; for (double re=-2.0; re<=0.5; re+=0.1) { @@ -271,14 +271,14 @@ private static int mandelperf() { } return mandel_sum; } - + private static void print_perf(String name, long t) { System.out.printf("java,%s,%.6f\n", name, t/(double)1E6); } private static int fib(int n) { return n < 2 ? n : fib(n-1) + fib(n-2); - } - + } + } diff --git a/test/perf/micro/java/src/main/java/PerfPure.java b/test/perf/micro/java/src/main/java/PerfPure.java index 8eb492164255c..ce65657d13920 100644 --- a/test/perf/micro/java/src/main/java/PerfPure.java +++ b/test/perf/micro/java/src/main/java/PerfPure.java @@ -9,7 +9,7 @@ public class PerfPure { private static final int NITER = 5; private static Random rand = new Random(0); - + public static void main(String[] args) { long t, tmin; @@ -49,7 +49,7 @@ public static void main(String[] args) { t = System.nanoTime()-t; if (t < tmin) tmin = t; } - assert(mandel_sum == 14720) : "value was "+mandel_sum; + assert(mandel_sum == 14720) : "value was "+mandel_sum; print_perf("mandel", tmin); // sort @@ -89,7 +89,7 @@ public static void main(String[] args) { if (t < tmin) tmin = t; } print_perf("rand_mat_stat", tmin); - + // rand mat mul tmin = Long.MAX_VALUE; for (int i=0; i elements) { double total = 0; for(Double d:elements) { double dif = (d-m); - total += dif*dif; + total += dif*dif; } return Math.sqrt(total/(elements.size()-1)); } - + public static double mean(List elements) { double total = 0; for(Double d:elements) { @@ -207,7 +207,7 @@ public static double mean(List elements) { } return total/elements.size(); } - + public static double stdev(SimpleMatrix sm) { double m = mean(sm); double total = 0; @@ -219,12 +219,12 @@ public static double stdev(SimpleMatrix sm) { } return Math.sqrt(total/(sm.getNumElements()-1)); } - + public static double mean(SimpleMatrix sm) { double total = 0; int i = sm.getNumElements(); while (--i>=0) { - total += sm.get(i); + total += sm.get(i); } return total/sm.getNumElements(); } @@ -280,19 +280,19 @@ private static int mandel(double zReal, double zImag) { n -= 1; break; } - + // z^2 double zSquaredReal = zReal*zReal-zImag*zImag; double zSquaredImag = zReal*zImag+zImag*zReal; - + // +c zReal = zSquaredReal+cReal; zImag = zSquaredImag+cImag; - + } return n+1; } - + private static double complexAbs(double zReal, double zImag) { return Math.sqrt(zReal*zReal + zImag*zImag); } @@ -307,7 +307,7 @@ private static int mandelperf() { } return mandel_sum; } - + private static void print_perf(String name, long t) { System.out.printf("javaPure,%s,%.6f\n", name, t/(double)1E6); } @@ -315,6 +315,6 @@ private static void print_perf(String name, long t) { private static int fib(int n) { return n < 2 ? n : fib(n-1) + fib(n-2); } - + } diff --git a/test/perf/micro/perf.c b/test/perf/micro/perf.c index 6fc6b4d9c1402..c7d793bf791a8 100644 --- a/test/perf/micro/perf.c +++ b/test/perf/micro/perf.c @@ -272,7 +272,7 @@ int main() { // if (t < tmin) tmin = t; // } // print_perf("ones", tmin); - // + // // // A*A' // //SUBROUTINE DGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC) // double *b = ones(200, 200); diff --git a/test/perf/micro/perf.do b/test/perf/micro/perf.do index 35d5e81e1c416..0119c93dde628 100644 --- a/test/perf/micro/perf.do +++ b/test/perf/micro/perf.do @@ -4,7 +4,7 @@ clear all mata // start mata code // fibonacci -real scalar fib(n) +real scalar fib(n) { if (n < 2) { return(n) @@ -25,7 +25,7 @@ void parse_int(real scalar t) { } // quick sort -real matrix qsort(real matrix a) +real matrix qsort(real matrix a) { return(qsort_kernel(a, 1, length(a))) } @@ -62,7 +62,7 @@ real matrix quicksort(n) // mandelbrot -real scalar mandelarg(z) +real scalar mandelarg(z) { c = z maxiter = 80 @@ -90,7 +90,7 @@ real matrix mandel() // pi series -real scalar pi_sum() +real scalar pi_sum() { real scalar sum sum = 0.0 @@ -107,7 +107,7 @@ real scalar pi_sum() // random matrix statistics real matrix rand_mat_stat(t) -{ +{ n = 5 m = J(n, 1, 0) s = J(n, 1, 1) @@ -177,7 +177,7 @@ args a lo hi local idx = floor((`lo' + `hi') / 2) scalar `pivot' = `a'[`idx'] while (`i' <= `j') { - while (`a'[`i'] < `pivot') { + while (`a'[`i'] < `pivot') { local ++i } while (`a'[`j'] > `pivot') { @@ -201,7 +201,7 @@ program quicksort args n drop _all set obs `n' - tempvar x + tempvar x g `x' = runiform() qsort_kernel `x' 1 `n' end @@ -244,7 +244,7 @@ end -// arguments +// arguments local fib 20 local parse_int 1000 local quicksort 5000 diff --git a/test/perf/micro/perf.go b/test/perf/micro/perf.go index 89c416f2f65a8..bde15e46d1a74 100644 --- a/test/perf/micro/perf.go +++ b/test/perf/micro/perf.go @@ -120,7 +120,7 @@ func randmatmul(n int) matrix.MatrixRO { return matrix.Product(a, b) } -// mandelbrot +// mandelbrot func mandel(z complex128) int { maxiter := 80 diff --git a/test/perf/micro/perf.js b/test/perf/micro/perf.js index 677899cdb6771..3ae22fd886b62 100644 --- a/test/perf/micro/perf.js +++ b/test/perf/micro/perf.js @@ -107,11 +107,11 @@ function rand(n) { var v, i; v = new Array(n); - + for (i = 0; i < n; i++) { v[i] = Math.random(); } - + return v; } @@ -148,7 +148,7 @@ var v = rand(n); qsort_kernel(v, 0, n); return v; - } + } tmin = Number.POSITIVE_INFINITY; for (i=0; i < 5; i++) { @@ -204,15 +204,15 @@ var subLen, len, i; subLen = sub.length; len = a.length; - + for (i = 0; i < subLen; i++) { a[i] = sub[i] = gaussian(); } - + for (i = subLen; i < len; i++) { a[i] = gaussian(); } - + return a; } @@ -220,7 +220,7 @@ var i, j; i = 0; j = 0; - + for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { dest[i*n+j] = src[j*m+i]; @@ -233,15 +233,15 @@ i = 0; j = 0; k = 0; - + for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { sum = 0.0; - + for (k = 0; k < l; k++) { sum += A[i*l+k]*B[k*n+j]; } - + dest[i*n+j] = sum; } } @@ -252,45 +252,45 @@ a, b, c, d, aSub, bSub, cSub, dSub, v, w, i, j, k, trP, trQ, v1, v2, w1, w2; n = 5; - + P = new Float64Array( 4*n*n ); Q = new Float64Array( 4*n*n ); - + PTransposed = new Float64Array( P.length ); QTransposed = new Float64Array( Q.length ); - + PMatMul = new Float64Array( n*n ); QMatMul = new Float64Array( (2*n) * (2*n) ); - + a = new Float64Array( n*n ); b = new Float64Array( n*n ); c = new Float64Array( n*n ); d = new Float64Array( n*n ); - + // the first n number of elements of a to d aSub = new Float64Array( n ); bSub = new Float64Array( n ); cSub = new Float64Array( n ); dSub = new Float64Array( n ); - + v = new Float64Array( t ); w = new Float64Array( t ); - + i = 0; j = 0; k = 0; - + for (i = 0; i < t; i++) { a = randn( a, aSub ); b = randn( b, bSub ); c = randn( c, cSub ); d = randn( d, dSub ); - + P.set( a, 0*n*n ); P.set( b, 1*n*n ); P.set( c, 2*n*n ); P.set( d, 3*n*n ); - + for (j = 0; j < n; j++) { Q.set( aSub, 2*n*j ); Q.set( bSub, 2*n*j+n ); @@ -305,30 +305,30 @@ } */ } - + transpose( PTransposed, P, n, 4*n ); matmulCopy( PMatMul, PTransposed, P, n, 4*n, n ); matmulCopy( PMatMul, P, P, n, n, n); matmulCopy( PMatMul, P, P, n, n, n); - + trP = 0; for (j = 0; j < n; j++) { trP += PMatMul[(n+1)*j]; } v[i] = trP; - + transpose( QTransposed, Q, 2*n, 2*n ); matmulCopy( QMatMul, QTransposed, Q, 2*n, 2*n, 2*n ); matmulCopy( QMatMul, Q, Q, 2*n, 2*n, 2*n); matmulCopy( QMatMul, Q, Q, 2*n, 2*n, 2*n); - + trQ = 0; for (j = 0; j < 2*n; j++) { trQ += QMatMul[(2*n+1)*j]; } w[i] = trQ; } - + v1 = 0.0; v2 = 0.0; w1 = 0.0; @@ -337,7 +337,7 @@ v1 += v[i]; v2 += v[i]*v[i]; w1 += w[i]; w2 += w[i]*w[i]; } - + return { s1: Math.sqrt((t*(t*v2-v1*v1))/((t-1)*v1*v1)), s2: Math.sqrt((t*(t*w2-w1*w1))/((t-1)*w1*w1)) @@ -362,11 +362,11 @@ function randFloat64(n) { var v, i; v = new Float64Array(n); - + for (i = 0; i < n; i++) { v[i] = Math.random(); } - + return v; } @@ -399,19 +399,19 @@ // custom multiplication routines, which // likely make use of such aligned memory. B = mattransp(B,l,n); - + for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { total = 0.0; - + for (k = 0; k < l; k++) { total += A[i*l+k]*B[j*l+k]; } - + C[i*n+j] = total; } } - + return C; } @@ -419,7 +419,7 @@ var A, B; A = randFloat64(n*n); B = randFloat64(n*n); - + return matmul(A, B, n, n, n); } diff --git a/test/perf/micro/perf.lua b/test/perf/micro/perf.lua index e622c86bab644..5e54048002d65 100644 --- a/test/perf/micro/perf.lua +++ b/test/perf/micro/perf.lua @@ -9,7 +9,7 @@ local rshift = bit.rshift local format = string.format local gettime -do +do ffi.cdef[[ struct timeval { long tv_sec; @@ -81,7 +81,7 @@ local function mandel(z) end return maxiter end -function mandelperf() +function mandelperf() local a, re, im, z a = ffi.new("double[?]", 546) r = 0 @@ -95,7 +95,7 @@ function mandelperf() return a end -do +do local a = mandelperf() local sum = 0 for i = 0, 545 do sum = sum + a[i] end @@ -216,7 +216,7 @@ end do local s1, s2 = randmatstat(1000) - assert( 0.5 < s1 and s1 < 1.0 + assert( 0.5 < s1 and s1 < 1.0 and 0.5 < s2 and s2 < 1.0 ) end diff --git a/test/perf/micro/perf.nb b/test/perf/micro/perf.nb index c9e7822300373..1212522613edd 100644 --- a/test/perf/micro/perf.nb +++ b/test/perf/micro/perf.nb @@ -38,7 +38,7 @@ On[Assert]; (* recursive fib *) ClearAll[fib]; -fib = Compile[{{n, _Integer}}, +fib = Compile[{{n, _Integer}}, If[n < 2, n, fib[n - 1] + fib[n - 2]], CompilationTarget -> "WVM" ]; @@ -219,11 +219,11 @@ ClearAll[randmatstat]; randmatstat = Compile[{{t, _Integer}}, Module[ { - n = 5, - v = ConstantArray[0., t], - w = ConstantArray[0., t], - a = {{0.}}, b = {{0.}}, - c = {{0.}}, d = {{0.}}, + n = 5, + v = ConstantArray[0., t], + w = ConstantArray[0., t], + a = {{0.}}, b = {{0.}}, + c = {{0.}}, d = {{0.}}, P = {{0.}}, Q = {{0.}} }, Do[ @@ -258,7 +258,7 @@ timeit[RandomReal[1, {1000, 1000}].RandomReal[1, {1000, 1000}], "rand_mat_mul"]; (* only on unix systems *) If[ $OperatingSystem == "Linux"||$OperatingSystem == "MacOSX", - + ClearAll[printfd]; printfd[n_] := Module[ {stream}, @@ -270,7 +270,7 @@ If[ $OperatingSystem == "Linux"||$OperatingSystem == "MacOSX", ]; Close[stream]; ]; - + timeit[printfd[100000], "printfd"]; - + ]; diff --git a/test/perf/perfcomp.jl b/test/perf/perfcomp.jl index 8bd06b1b51607..3a3d1b8c865ce 100644 --- a/test/perf/perfcomp.jl +++ b/test/perf/perfcomp.jl @@ -13,12 +13,12 @@ function main() torun = length(ARGS) > 1 ? ARGS[2] : "all" io,p = readsfrom(`make -s $torun`) newp = readperf(io) - + names = sort(intersect(keys(baseline),keys(newp))) - + means0 = [ baseline[n][3] for n in names ] means1 = [ newp[n][3] for n in names ] - + change = (means0 - means1) ./ means0 println("test name old new % speedup % st. dev") diff --git a/test/perf/perfutil.jl b/test/perf/perfutil.jl index 41a4c97c3deb0..0cfc8fbf6b1da 100644 --- a/test/perf/perfutil.jl +++ b/test/perf/perfutil.jl @@ -24,7 +24,7 @@ end # Takes in the raw array of values in vals, along with the benchmark name, description, unit and whether less is better function submit_to_codespeed(vals,name,desc,unit,test_group,lessisbetter=true) - # Points to the server + # Points to the server codespeed_host = "julia-codespeed.csail.mit.edu" csdata["benchmark"] = name @@ -56,7 +56,7 @@ macro output_timings(t,name,desc,group) elseif print_output @printf "julia,%s,%f,%f,%f,%f\n" $name minimum($t) maximum($t) mean($t) std($t) end - gc() + gc() end end diff --git a/test/perf/shootout/Makefile b/test/perf/shootout/Makefile index c75b2c9fadf3f..622e92708e0b9 100644 --- a/test/perf/shootout/Makefile +++ b/test/perf/shootout/Makefile @@ -1,7 +1,7 @@ JULIAHOME = $(abspath ../../..) include ../../../Make.inc -SHOOTOUTFILES = knucleotide-input.txt regexdna-input.txt revcomp-input.txt fasta-output.txt mandelbrot-output.txt nbody-output.txt fannkuchredux-output.txt pidigits-output.txt knucleotide-output.txt revcomp-output.txt spectralnorm-output.txt regexdna-output.txt meteor-output.txt +SHOOTOUTFILES = knucleotide-input.txt regexdna-input.txt revcomp-input.txt fasta-output.txt mandelbrot-output.txt nbody-output.txt fannkuchredux-output.txt pidigits-output.txt knucleotide-output.txt revcomp-output.txt spectralnorm-output.txt regexdna-output.txt meteor-output.txt getall: $(SHOOTOUTFILES) diff --git a/test/perf/shootout/binary_trees.jl b/test/perf/shootout/binary_trees.jl index 4cd722a5f6fb3..549a83d7cfb8c 100644 --- a/test/perf/shootout/binary_trees.jl +++ b/test/perf/shootout/binary_trees.jl @@ -2,9 +2,9 @@ # The Computer Language Benchmarks Game # binary-trees benchmark # http://shootout.alioth.debian.org/u32/performance.php?test=binarytrees -# +# # Ported from an OCaml version -# +# abstract BTree @@ -18,9 +18,9 @@ type Node <: BTree end function make(val, d) - if d == 0 + if d == 0 Node(val, Empty(), Empty()) - else + else nval = val * 2 Node(val, make(nval-1, d-1), make(nval, d-1)) end @@ -37,7 +37,7 @@ function loop_depths(d, min_depth, max_depth) c += check(make(i, d)) + check(make(-i, d)) end # @printf("%i\t trees of depth %i\t check: %i\n", 2*niter, d, c) - d += 2 + d += 2 end end diff --git a/test/perf/shootout/nbody.jl b/test/perf/shootout/nbody.jl index 9f09ebc461871..27eabc78b9754 100644 --- a/test/perf/shootout/nbody.jl +++ b/test/perf/shootout/nbody.jl @@ -1,10 +1,10 @@ -# +# # The Computer Language Benchmarks Game # nbody benchmark # http://shootout.alioth.debian.org/u32/performance.php?test=nbody # # A straight port from the Java version -# +# module NBody @@ -71,7 +71,7 @@ end function energy(bodies) local e::Float64 = 0.0 for i = 1:length(bodies) - e += 0.5 * bodies[i].mass * + e += 0.5 * bodies[i].mass * (bodies[i].vx^2 + bodies[i].vy^2 + bodies[i].vz^2) for j = i+1:length(bodies) dx = bodies[i].x - bodies[j].x @@ -93,7 +93,7 @@ function nbody(N::Int=1000) 7.69901118419740425e-03 * days_per_year, # vy -6.90460016972063023e-05 * days_per_year, # vz 9.54791938424326609e-04 * solar_mass) # mass - + saturn = Body( 8.34336671824457987e+00, 4.12479856412430479e+00, -4.03523417114321381e-01, @@ -101,7 +101,7 @@ function nbody(N::Int=1000) 4.99852801234917238e-03 * days_per_year, 2.30417297573763929e-05 * days_per_year, 2.85885980666130812e-04 * solar_mass) - + uranus = Body( 1.28943695621391310e+01, -1.51111514016986312e+01, -2.23307578892655734e-01, @@ -109,7 +109,7 @@ function nbody(N::Int=1000) 2.37847173959480950e-03 * days_per_year, -2.96589568540237556e-05 * days_per_year, 4.36624404335156298e-05 * solar_mass) - + neptune = Body( 1.53796971148509165e+01, -2.59193146099879641e+01, 1.79258772950371181e-01, @@ -117,9 +117,9 @@ function nbody(N::Int=1000) 1.62824170038242295e-03 * days_per_year, -9.51592254519715870e-05 * days_per_year, 5.15138902046611451e-05 * solar_mass) - + sun = Body(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, solar_mass) - + bodies = [sun, jupiter, saturn, uranus, neptune] init_sun(bodies) diff --git a/test/perf/shootout/nbody_vec.jl b/test/perf/shootout/nbody_vec.jl index 887572081610b..0f8db04c1af6a 100644 --- a/test/perf/shootout/nbody_vec.jl +++ b/test/perf/shootout/nbody_vec.jl @@ -1,10 +1,10 @@ -# +# # The Computer Language Benchmarks Game # nbody benchmark # http://shootout.alioth.debian.org/u32/performance.php?test=nbody # # A vectorized version of the Java port from nbody.jl -# +# module NBodyVec @@ -52,7 +52,7 @@ end function energy(bodies) local e::Float64 = 0.0 for i = 1:length(bodies) - e += 0.5 * bodies[i].mass * + e += 0.5 * bodies[i].mass * sum(bodies[i].v .^ 2) for j = i+1:length(bodies) delta = bodies[i].pos - bodies[j].pos @@ -72,7 +72,7 @@ function nbody_vec(N::Int=1000) 7.69901118419740425e-03 * days_per_year, # v[2] = vy -6.90460016972063023e-05 * days_per_year], # v[3] = vz 9.54791938424326609e-04 * solar_mass) # mass - + saturn = Body( [8.34336671824457987e+00, 4.12479856412430479e+00, -4.03523417114321381e-01], @@ -80,7 +80,7 @@ function nbody_vec(N::Int=1000) 4.99852801234917238e-03 * days_per_year, 2.30417297573763929e-05 * days_per_year], 2.85885980666130812e-04 * solar_mass) - + uranus = Body( [1.28943695621391310e+01, -1.51111514016986312e+01, -2.23307578892655734e-01], @@ -88,7 +88,7 @@ function nbody_vec(N::Int=1000) 2.37847173959480950e-03 * days_per_year, -2.96589568540237556e-05 * days_per_year], 4.36624404335156298e-05 * solar_mass) - + neptune = Body( [1.53796971148509165e+01, -2.59193146099879641e+01, 1.79258772950371181e-01], @@ -96,9 +96,9 @@ function nbody_vec(N::Int=1000) 1.62824170038242295e-03 * days_per_year, -9.51592254519715870e-05 * days_per_year], 5.15138902046611451e-05 * solar_mass) - + sun = Body([0.0, 0.0, 0.0], [0.0, 0.0, 0.0], solar_mass) - + bodies = [sun, jupiter, saturn, uranus, neptune] init_sun(bodies) diff --git a/test/perf/shootout/pidigits.jl b/test/perf/shootout/pidigits.jl index ae272bc1eec75..723a53e44d407 100644 --- a/test/perf/shootout/pidigits.jl +++ b/test/perf/shootout/pidigits.jl @@ -14,7 +14,7 @@ function pidigits(N::Int, printOut::Bool) OUTPUT: - returns the last ten digits anyway - + - prints all the digits in packets of 10 iff printOut == true """ diff --git a/test/perf/shootout/spectralnorm.jl b/test/perf/shootout/spectralnorm.jl index 2cb6796a7c484..c3c868ce53139 100644 --- a/test/perf/shootout/spectralnorm.jl +++ b/test/perf/shootout/spectralnorm.jl @@ -4,7 +4,7 @@ # http://shootout.alioth.debian.org/u32/performance.php?test=spectralnorm # # Based on the Javascript program -# +# A(i,j) = 1.0 / ((i+j)*(i+j+1.0)/2.0+i+1.0) diff --git a/test/perf/simd/axpy.jl b/test/perf/simd/axpy.jl index 0c14a9538427b..c62b2276a18e1 100644 --- a/test/perf/simd/axpy.jl +++ b/test/perf/simd/axpy.jl @@ -1,6 +1,6 @@ # Compute y += a*x using @simd for vectors x and y function simd_axpy( a, x, y ) - # LLVM's auto-vectorizer typically vectorizes this loop even without @simd + # LLVM's auto-vectorizer typically vectorizes this loop even without @simd @simd for i=1:length(x) @inbounds y[i] += a*x[i] end diff --git a/test/perf/simd/seismic_fdtd.jl b/test/perf/simd/seismic_fdtd.jl index b58239cd9fbe6..2d40e12285d8a 100644 --- a/test/perf/simd/seismic_fdtd.jl +++ b/test/perf/simd/seismic_fdtd.jl @@ -1,6 +1,6 @@ # Finite-difference time-domain seismic simulation in 2D using a staggered grid. # The intent is to test performance of @simd on the inner loop of a 2D loop nest. -# +# # If @simd ever supports forward-lexical dependences, then the kernels in updateV # and updateU can be merged. @@ -9,7 +9,7 @@ function updateV( irange, jrange, U, Vx, Vy, A ) for j in jrange @simd for i in irange @inbounds begin - Vx[i,j] += (A[i,j+1]+A[i,j])*(U[i,j+1]-U[i,j]) + Vx[i,j] += (A[i,j+1]+A[i,j])*(U[i,j+1]-U[i,j]) Vy[i,j] += (A[i+1,j]+A[i,j])*(U[i+1,j]-U[i,j]) end end @@ -28,11 +28,11 @@ function updateU( irange, jrange, U, Vx, Vy, B ) end # Alternate updates for given number of steps -function flog_fdtd( steps, U, Vx, Vy, A, B ) +function flog_fdtd( steps, U, Vx, Vy, A, B ) m,n = size(U) for k=1:steps - updateV(2:m-1,2:n-1,U,Vx,Vy,A) - updateU(2:m-1,2:n-1,U,Vx,Vy,B) + updateV(2:m-1,2:n-1,U,Vx,Vy,A) + updateU(2:m-1,2:n-1,U,Vx,Vy,B) end end diff --git a/test/perf/simd/sum_reduce.jl b/test/perf/simd/sum_reduce.jl index c46afced580ae..5fa61e6d3d921 100644 --- a/test/perf/simd/sum_reduce.jl +++ b/test/perf/simd/sum_reduce.jl @@ -12,7 +12,7 @@ function flog_sum_reduce( m, x ) # Try different starting and ending indices. sum_reduce(x,j,length(x)-(j-1)) end - s + s end for t in [Float32,Float64] diff --git a/test/perf/sort/perf.jl b/test/perf/sort/perf.jl index 5f8c46d3c85b5..f91b4d7a24269 100644 --- a/test/perf/sort/perf.jl +++ b/test/perf/sort/perf.jl @@ -32,8 +32,8 @@ if codespeed end end else - for (T, typename, randfn!) in [(Int, string(Int), randint_fn!(10)), - (Float64, string(Float64), rand!), + for (T, typename, randfn!) in [(Int, string(Int), randint_fn!(10)), + (Float64, string(Float64), rand!), (AbstractString, "String_05", randstr_fn!(5)), (AbstractString, "String_10", randstr_fn!(10))] for logsize = 6:2:18 @@ -59,20 +59,20 @@ else ## Sorted with 3 exchanges name = "$(typename)_$(logsize)_$(string(s)[1:end-5])_3exchanges" - @timeit_init(sort!(data, alg=s), + @timeit_init(sort!(data, alg=s), begin for i = 1:3 n1 = rand(1:size) n2 = rand(1:size) data[n1], data[n2] = data[n2], data[n1] end - end, + end, name, "") ## Sorted with 10 unsorted values appended name = "$(typename)_$(logsize)_$(string(s)[1:end-5])_append" @timeit_init(sort!(data, alg=s), begin data[end-9:end]=randfn!(Array(T,10)) end, name, "") - + ## Random data with 4 unique values name = "$(typename)_$(logsize)_$(string(s)[1:end-5])_4unique" @timeit_init(sort!(data4, alg=s), begin data4=data[rand(1:4,size)] end, name, "") diff --git a/test/perf/sparse/perf.jl b/test/perf/sparse/perf.jl index addf9b8ada905..6840e78396a96 100644 --- a/test/perf/sparse/perf.jl +++ b/test/perf/sparse/perf.jl @@ -39,7 +39,7 @@ push!(us, sprand(large, large, 1e-3)) uus = [] for u in us push!(uus, SparseMatrixCSC(u.m, u.n, uint32(u.colptr), uint32(u.rowval), u.nzval)) -end +end ## getindex rep = 20 @@ -53,12 +53,12 @@ function integer_indexing(A) for i in rand(rI, reps) for j in rand(rJ, rep) tmp += A[i,j] - end + end end tmp end -function row_indexing(A, rowinds) +function row_indexing(A, rowinds) # index rows with rowinds and columns with a random integer nI, nJ = size(A) rI = 1:nI @@ -70,7 +70,7 @@ function row_indexing(A, rowinds) tmp end -function col_indexing(A, colinds) +function col_indexing(A, colinds) # index rows with a random integer and columns with colinds nI, nJ = size(A) rI = 1:nI @@ -135,8 +135,8 @@ sizes = [(1, "small", "Small sparse matrix"), (2, "medium", "Medium sparse matri mattyp = [(ts, "10 entries/column"), (us, "100 entries/column"), (uus, "100 entries/column uint32")] # - functions -funs = [(integer_indexing, 1, "indexing"), (one_arg_indexing, 1, "1d indexing"), - (row_indexing, 2, "indexing rows"), (col_indexing, 2, "indexing columns"), +funs = [(integer_indexing, 1, "indexing"), (one_arg_indexing, 1, "1d indexing"), + (row_indexing, 2, "indexing rows"), (col_indexing, 2, "indexing columns"), (row_col_indexing, 3, "indexing rows & columns")] # performance tests: diff --git a/test/perf/spell/perf.jl b/test/perf/spell/perf.jl index 37b08666e144e..24056211cdd47 100644 --- a/test/perf/spell/perf.jl +++ b/test/perf/spell/perf.jl @@ -3,9 +3,9 @@ # I've attempted to keep this close to the python version, although in some cases # the python version is tighter because of some syntax that is not available in julia -# (e.g., guards in comprehensions). +# (e.g., guards in comprehensions). # -# The python version, at the time of original submission, is also 5-6x faster than +# The python version, at the time of original submission, is also 5-6x faster than # the julia version. # # @kmsquire, 2013-11-29 @@ -92,7 +92,7 @@ function spelltest(tests; bias=0, verbose=false) end end - return ["bad"=>bad, "n"=>n, "bias"=>bias, "pct"=>int(100. - 100.*bad/n), + return ["bad"=>bad, "n"=>n, "bias"=>bias, "pct"=>int(100. - 100.*bad/n), "unknown"=>unknown, "secs"=>toc() ] end @@ -103,15 +103,15 @@ const tests1 = [ "access"=> "acess", "accessing"=> "accesing", "accommodation"=> "aunt"=> "annt anut arnt", "auxiliary"=> "auxillary", "available"=> "avaible", "awful"=> "awfall afful", "basically"=> "basicaly", "beginning"=> "begining", "benefit"=> "benifit", "benefits"=> "benifits", "between"=> "beetween", "bicycle"=> -"bicycal bycicle bycycle", "biscuits"=> -"biscits biscutes biscuts bisquits buiscits buiscuts", "built"=> "biult", +"bicycal bycicle bycycle", "biscuits"=> +"biscits biscutes biscuts bisquits buiscits buiscuts", "built"=> "biult", "cake"=> "cak", "career"=> "carrer", "cemetery"=> "cemetary semetary", "centrally"=> "centraly", "certain"=> "cirtain", "challenges"=> "chalenges chalenges", "chapter"=> "chaper chaphter chaptur", "choice"=> "choise", "choosing"=> "chosing", "clerical"=> "clearical", "committee"=> "comittee", "compare"=> "compair", "completely"=> "completly", "consider"=> "concider", "considerable"=> "conciderable", "contented"=> -"contenpted contende contended contentid", "curtains"=> +"contenpted contende contended contentid", "curtains"=> "cartains certans courtens cuaritains curtans curtians curtions", "decide"=> "descide", "decided"=> "descided", "definitely"=> "definately difinately", "definition"=> "defenition", "definitions"=> "defenitions", "description"=> "discription", "desiccate"=> @@ -120,39 +120,39 @@ const tests1 = [ "access"=> "acess", "accessing"=> "accesing", "accommodation"=> "embarrass"=> "embaras embarass", "establishing"=> "astablishing establising", "experience"=> "experance experiance", "experiences"=> "experances", "extended"=> "extented", "extremely"=> "extreamly", "fails"=> "failes", "families"=> "familes", -"february"=> "febuary", "further"=> "futher", "gallery"=> "galery gallary gallerry gallrey", +"february"=> "febuary", "further"=> "futher", "gallery"=> "galery gallary gallerry gallrey", "hierarchal"=> "hierachial", "hierarchy"=> "hierchy", "inconvenient"=> "inconvienient inconvient inconvinient", "independent"=> "independant independant", "initial"=> "intial", "initials"=> "inetials inistals initails initals intials", -"juice"=> "guic juce jucie juise juse", "latest"=> "lates latets latiest latist", +"juice"=> "guic juce jucie juise juse", "latest"=> "lates latets latiest latist", "laugh"=> "lagh lauf laught lugh", "level"=> "leval", "levels"=> "levals", "liaison"=> "liaision liason", "lieu"=> "liew", "literature"=> -"litriture", "loans"=> "lones", "locally"=> "localy", "magnificent"=> +"litriture", "loans"=> "lones", "locally"=> "localy", "magnificent"=> "magnificnet magificent magnifcent magnifecent magnifiscant magnifisent magnificant", "management"=> "managment", "meant"=> "ment", "minuscule"=> "miniscule", -"minutes"=> "muinets", "monitoring"=> "monitering", "necessary"=> +"minutes"=> "muinets", "monitoring"=> "monitering", "necessary"=> "neccesary necesary neccesary necassary necassery neccasary", "occurrence"=> -"occurence occurence", "often"=> "ofen offen offten ofton", "opposite"=> -"opisite oppasite oppesite oppisit oppisite opposit oppossite oppossitte", "parallel"=> +"occurence occurence", "often"=> "ofen offen offten ofton", "opposite"=> +"opisite oppasite oppesite oppisit oppisite opposit oppossite oppossitte", "parallel"=> "paralel paralell parrallel parralell parrallell", "particular"=> "particulaur", "perhaps"=> "perhapse", "personnel"=> "personnell", "planned"=> "planed", "poem"=> -"poame", "poems"=> "poims pomes", "poetry"=> "poartry poertry poetre poety powetry", -"position"=> "possition", "possible"=> "possable", "pretend"=> +"poame", "poems"=> "poims pomes", "poetry"=> "poartry poertry poetre poety powetry", +"position"=> "possition", "possible"=> "possable", "pretend"=> "pertend protend prtend pritend", "problem"=> "problam proble promblem proplen", "pronunciation"=> "pronounciation", "purple"=> "perple perpul poarple", "questionnaire"=> "questionaire", "really"=> "realy relley relly", "receipt"=> "receit receite reciet recipt", "receive"=> "recieve", "refreshment"=> "reafreshment refreshmant refresment refressmunt", "remember"=> "rember remeber rememmer rermember", -"remind"=> "remine remined", "scarcely"=> "scarcly scarecly scarely scarsely", +"remind"=> "remine remined", "scarcely"=> "scarcly scarecly scarely scarsely", "scissors"=> "scisors sissors", "separate"=> "seperate", "singular"=> "singulaur", "someone"=> "somone", "sources"=> "sorces", "southern"=> -"southen", "special"=> "speaical specail specal speical", "splendid"=> -"spledid splended splened splended", "standardizing"=> "stanerdizing", "stomach"=> +"southen", "special"=> "speaical specail specal speical", "splendid"=> +"spledid splended splened splended", "standardizing"=> "stanerdizing", "stomach"=> "stomac stomache stomec stumache", "supersede"=> "supercede superceed", "there"=> "ther", "totally"=> "totaly", "transferred"=> "transfred", "transportability"=> -"transportibility", "triangular"=> "triangulaur", "understand"=> "undersand undistand", +"transportibility", "triangular"=> "triangulaur", "understand"=> "undersand undistand", "unexpected"=> "unexpcted unexpeted unexspected", "unfortunately"=> -"unfortunatly", "unique"=> "uneque", "useful"=> "usefull", "valuable"=> "valubale valuble", +"unfortunatly", "unique"=> "uneque", "useful"=> "usefull", "valuable"=> "valubale valuble", "variable"=> "varable", "variant"=> "vairiant", "various"=> "vairious", "visited"=> "fisited viseted vistid vistied", "visitors"=> "vistors", "voluntary"=> "volantry", "voting"=> "voteing", "wanted"=> "wantid wonted", diff --git a/test/readdlm.jl b/test/readdlm.jl index 890f2794a01bd..4292c6dbc0775 100644 --- a/test/readdlm.jl +++ b/test/readdlm.jl @@ -59,7 +59,7 @@ let result1 = reshape(Any["t", "c", "", "c"], 2, 2), @test isequaldlm(readdlm(IOBuffer("t t \n\"\"\"c\" c")), result2, Any) end -@test isequaldlm(readcsv(IOBuffer("\n1,2,3\n4,5,6\n\n\n"), skipblanks=false), +@test isequaldlm(readcsv(IOBuffer("\n1,2,3\n4,5,6\n\n\n"), skipblanks=false), reshape(Any["",1.0,4.0,"","","",2.0,5.0,"","","",3.0,6.0,"",""], 5, 3), Any) @test isequaldlm(readcsv(IOBuffer("\n1,2,3\n4,5,6\n\n\n"), skipblanks=true), reshape([1.0,4.0,2.0,5.0,3.0,6.0], 2, 3), Float64) @test isequaldlm(readcsv(IOBuffer("1,2\n\n4,5"), skipblanks=false), reshape(Any[1.0,"",4.0,2.0,"",5.0], 3, 2), Any) @@ -130,58 +130,58 @@ let x = ["a" "b" "\nc"; "d" "\ne" "f"; "g" "h" "i\n"; "A" "B" "C"; 1 2 3; 4 5 6; end # source: http://www.i18nguy.com/unicode/unicode-example-utf8.zip -let i18n_data = ["Origin (English)", "Name (English)", "Origin (Native)", "Name (Native)", - "Australia", "Nicole Kidman", "Australia", "Nicole Kidman", - "Austria", "Johann Strauss", "Österreich", "Johann Strauß", - "Belgium (Flemish)", "Rene Magritte", "België", "René Magritte", - "Belgium (French)", "Rene Magritte", "Belgique", "René Magritte", - "Belgium (German)", "Rene Magritte", "Belgien", "René Magritte", - "Bhutan", "Gonpo Dorji", "འབྲུག་ཡུལ།", "མགོན་པོ་རྡོ་རྗེ།", - "Canada", "Celine Dion", "Canada", "Céline Dion", - "Canada - Nunavut (Inuktitut)", "Susan Aglukark", "ᓄᓇᕗᒻᒥᐅᑦ", "ᓱᓴᓐ ᐊᒡᓗᒃᑲᖅ", - "Democratic People's Rep. of Korea", "LEE Sol-Hee", "조선 민주주의 인민 공화국", "이설희", - "Denmark", "Soren Hauch-Fausboll", "Danmark", "Søren Hauch-Fausbøll", - "Denmark", "Soren Kierkegaard", "Danmark", "Søren Kierkegård", - "Egypt", "Abdel Halim Hafez", "ﻣﺼﺮ", "ﻋﺑﺪﺍﻠﺣﻟﻳﻢ ﺤﺎﻓﻅ", - "Egypt", "Om Kolthoum", "ﻣﺼﺮ", "ﺃﻡ ﻛﻟﺛﻭﻡ", - "Eritrea", "Berhane Zeray", "ብርሃነ ዘርኣይ", "ኤርትራ", - "Ethiopia", "Haile Gebreselassie", "ኃይሌ ገብረሥላሴ", "ኢትዮጵያ", - "France", "Gerard Depardieu", "France", "Gérard Depardieu", - "France", "Jean Reno", "France", "Jean Réno", - "France", "Camille Saint-Saens", "France", "Camille Saint-Saëns", - "France", "Mylene Demongeot", "France", "Mylène Demongeot", - "France", "Francois Truffaut", "France", "François Truffaut", - "France (Braille)", "Louis Braille", "⠋⠗⠁⠝⠉⠑", "⠇⠕⠥⠊⠎⠀
⠃⠗⠁⠊⠇⠇⠑", - "Georgia", "Eduard Shevardnadze", "საქართველო", "ედუარდ შევარდნაძე", - "Germany", "Rudi Voeller", "Deutschland", "Rudi Völler", - "Germany", "Walter Schultheiss", "Deutschland", "Walter Schultheiß", - "Greece", "Giorgos Dalaras", "Ελλάς", "Γιώργος Νταλάρας", - "Iceland", "Bjork Gudmundsdottir", "Ísland", "Björk Guðmundsdóttir", - "India (Hindi)", "Madhuri Dixit", "भारत", "माधुरी दिछित", - "Ireland", "Sinead O'Connor", "Éire", "Sinéad O'Connor", - "Israel", "Yehoram Gaon", "ישראל", "יהורם גאון", - "Italy", "Fabrizio DeAndre", "Italia", "Fabrizio De André", - "Japan", "KUBOTA Toshinobu", "日本", "久保田    利伸", - "Japan", "HAYASHIBARA Megumi", "日本", "林原 めぐみ", - "Japan", "Mori Ogai", "日本", "森鷗外", - "Japan", "Tex Texin", "日本", "テクス テクサン", - "Norway", "Tor Age Bringsvaerd", "Noreg", "Tor Åge Bringsværd", - "Pakistan (Urdu)", "Nusrat Fatah Ali Khan", "پاکستان", "نصرت فتح علی خان", - "People's Rep. of China", "ZHANG Ziyi", "中国", "章子怡", - "People's Rep. of China", "WONG Faye", "中国", "王菲", - "Poland", "Lech Walesa", "Polska", "Lech Wałęsa", - "Puerto Rico", "Olga Tanon", "Puerto Rico", "Olga Tañón", - "Rep. of China", "Hsu Chi", "臺灣", "舒淇", - "Rep. of China", "Ang Lee", "臺灣", "李安", - "Rep. of Korea", "AHN Sung-Gi", "한민국", "안성기", - "Rep. of Korea", "SHIM Eun-Ha", "한민국", "심은하", - "Russia", "Mikhail Gorbachev", "Россия", "Михаил Горбачёв", - "Russia", "Boris Grebenshchikov", "Россия", "Борис Гребенщиков", - "Slovenia", "\"Frane \"\"Jezek\"\" Milcinski", "Slovenija", "Frane Milčinski - Ježek", - "Syracuse (Sicily)", "Archimedes", "Συρακούσα", "Ἀρχιμήδης", - "Thailand", "Thongchai McIntai", "ประเทศไทย", "ธงไชย แม็คอินไตย์", - "U.S.A.", "Brad Pitt", "U.S.A.", "Brad Pitt", - "Yugoslavia (Cyrillic)", "Djordje Balasevic", "Југославија", "Ђорђе Балашевић", +let i18n_data = ["Origin (English)", "Name (English)", "Origin (Native)", "Name (Native)", + "Australia", "Nicole Kidman", "Australia", "Nicole Kidman", + "Austria", "Johann Strauss", "Österreich", "Johann Strauß", + "Belgium (Flemish)", "Rene Magritte", "België", "René Magritte", + "Belgium (French)", "Rene Magritte", "Belgique", "René Magritte", + "Belgium (German)", "Rene Magritte", "Belgien", "René Magritte", + "Bhutan", "Gonpo Dorji", "འབྲུག་ཡུལ།", "མགོན་པོ་རྡོ་རྗེ།", + "Canada", "Celine Dion", "Canada", "Céline Dion", + "Canada - Nunavut (Inuktitut)", "Susan Aglukark", "ᓄᓇᕗᒻᒥᐅᑦ", "ᓱᓴᓐ ᐊᒡᓗᒃᑲᖅ", + "Democratic People's Rep. of Korea", "LEE Sol-Hee", "조선 민주주의 인민 공화국", "이설희", + "Denmark", "Soren Hauch-Fausboll", "Danmark", "Søren Hauch-Fausbøll", + "Denmark", "Soren Kierkegaard", "Danmark", "Søren Kierkegård", + "Egypt", "Abdel Halim Hafez", "ﻣﺼﺮ", "ﻋﺑﺪﺍﻠﺣﻟﻳﻢ ﺤﺎﻓﻅ", + "Egypt", "Om Kolthoum", "ﻣﺼﺮ", "ﺃﻡ ﻛﻟﺛﻭﻡ", + "Eritrea", "Berhane Zeray", "ብርሃነ ዘርኣይ", "ኤርትራ", + "Ethiopia", "Haile Gebreselassie", "ኃይሌ ገብረሥላሴ", "ኢትዮጵያ", + "France", "Gerard Depardieu", "France", "Gérard Depardieu", + "France", "Jean Reno", "France", "Jean Réno", + "France", "Camille Saint-Saens", "France", "Camille Saint-Saëns", + "France", "Mylene Demongeot", "France", "Mylène Demongeot", + "France", "Francois Truffaut", "France", "François Truffaut", + "France (Braille)", "Louis Braille", "⠋⠗⠁⠝⠉⠑", "⠇⠕⠥⠊⠎⠀
⠃⠗⠁⠊⠇⠇⠑", + "Georgia", "Eduard Shevardnadze", "საქართველო", "ედუარდ შევარდნაძე", + "Germany", "Rudi Voeller", "Deutschland", "Rudi Völler", + "Germany", "Walter Schultheiss", "Deutschland", "Walter Schultheiß", + "Greece", "Giorgos Dalaras", "Ελλάς", "Γιώργος Νταλάρας", + "Iceland", "Bjork Gudmundsdottir", "Ísland", "Björk Guðmundsdóttir", + "India (Hindi)", "Madhuri Dixit", "भारत", "माधुरी दिछित", + "Ireland", "Sinead O'Connor", "Éire", "Sinéad O'Connor", + "Israel", "Yehoram Gaon", "ישראל", "יהורם גאון", + "Italy", "Fabrizio DeAndre", "Italia", "Fabrizio De André", + "Japan", "KUBOTA Toshinobu", "日本", "久保田    利伸", + "Japan", "HAYASHIBARA Megumi", "日本", "林原 めぐみ", + "Japan", "Mori Ogai", "日本", "森鷗外", + "Japan", "Tex Texin", "日本", "テクス テクサン", + "Norway", "Tor Age Bringsvaerd", "Noreg", "Tor Åge Bringsværd", + "Pakistan (Urdu)", "Nusrat Fatah Ali Khan", "پاکستان", "نصرت فتح علی خان", + "People's Rep. of China", "ZHANG Ziyi", "中国", "章子怡", + "People's Rep. of China", "WONG Faye", "中国", "王菲", + "Poland", "Lech Walesa", "Polska", "Lech Wałęsa", + "Puerto Rico", "Olga Tanon", "Puerto Rico", "Olga Tañón", + "Rep. of China", "Hsu Chi", "臺灣", "舒淇", + "Rep. of China", "Ang Lee", "臺灣", "李安", + "Rep. of Korea", "AHN Sung-Gi", "한민국", "안성기", + "Rep. of Korea", "SHIM Eun-Ha", "한민국", "심은하", + "Russia", "Mikhail Gorbachev", "Россия", "Михаил Горбачёв", + "Russia", "Boris Grebenshchikov", "Россия", "Борис Гребенщиков", + "Slovenia", "\"Frane \"\"Jezek\"\" Milcinski", "Slovenija", "Frane Milčinski - Ježek", + "Syracuse (Sicily)", "Archimedes", "Συρακούσα", "Ἀρχιμήδης", + "Thailand", "Thongchai McIntai", "ประเทศไทย", "ธงไชย แม็คอินไตย์", + "U.S.A.", "Brad Pitt", "U.S.A.", "Brad Pitt", + "Yugoslavia (Cyrillic)", "Djordje Balasevic", "Југославија", "Ђорђе Балашевић", "Yugoslavia (Latin)", "Djordje Balasevic", "Jugoslavija", "Đorđe Balašević"] i18n_arr = transpose(reshape(i18n_data, 4, int(floor(length(i18n_data)/4)))) diff --git a/test/regex.jl b/test/regex.jl index 7a82e9a442d7c..bf224804ec3e2 100644 --- a/test/regex.jl +++ b/test/regex.jl @@ -4,7 +4,7 @@ function collect_eachmatch(re, str, overlap=false) end for f in [matchall, collect_eachmatch] - @test f(r"a?b?", "asbd") == ["a","","b","",""] == f(r"""a?b?""", "asbd") + @test f(r"a?b?", "asbd") == ["a","","b","",""] == f(r"""a?b?""", "asbd") @test f(r"a?b?", "asbd", true) == ["a","","b","",""] @test f(r"\w+", "hello", true) == ["hello","ello","llo","lo","o"] @test f(r".\s", "x \u2200 x \u2203 y") == ["x ", "∀ ", "x ", "∃ "] diff --git a/test/repl.jl b/test/repl.jl index f82f58edcdbb8..e44d82a556ce6 100644 --- a/test/repl.jl +++ b/test/repl.jl @@ -161,7 +161,7 @@ begin LineEdit.accept_result(s, histp) @test LineEdit.mode(s) == shell_mode @test buffercontents(LineEdit.buffer(s)) == "ll" - + # Issue #7551 # Enter search mode and try accepting an empty result REPL.history_reset_state(hp) diff --git a/test/replcompletions.jl b/test/replcompletions.jl index ea1f372d1947d..c4917f778f01c 100644 --- a/test/replcompletions.jl +++ b/test/replcompletions.jl @@ -164,21 +164,21 @@ end c,r = test_scomplete(s) @test r == length(s)+1:length(s) @test temp_name * "\\\\" in c - + s = "ls $(file[1:2])" c,r = test_scomplete(s) @test r == length(s)-1:length(s) @test file in c - + s = "cd(\"..\\" c,r = test_complete(s) @test r == length(s)+1:length(s) - @test temp_name * "\\\\" in c - + @test temp_name * "\\\\" in c + s = "cd(\"$(file[1:2])" c,r = test_complete(s) @test r == length(s) - 1:length(s) - @test file in c + @test file in c end rm(tmp) end diff --git a/test/rounding.jl b/test/rounding.jl index e406f22b72fc5..60570af02a561 100644 --- a/test/rounding.jl +++ b/test/rounding.jl @@ -16,7 +16,7 @@ d = prevfloat(1.) @test b - a === c # RoundToZero -with_rounding(Float64,RoundToZero) do +with_rounding(Float64,RoundToZero) do @test a + b === d @test - a - b === -d @test a - b === -c @@ -30,7 +30,7 @@ end @test b - a == c # RoundUp -with_rounding(Float64,RoundUp) do +with_rounding(Float64,RoundUp) do @test a + b === 1. @test - a - b === -d @test a - b === -c @@ -38,7 +38,7 @@ with_rounding(Float64,RoundUp) do end # RoundDown -with_rounding(Float64,RoundDown) do +with_rounding(Float64,RoundDown) do @test a + b === d @test - a - b === -1. @test a - b === -c @@ -59,7 +59,7 @@ d32 = prevfloat(1.0f0) @test b32 - a32 === c32 # RoundToZero -with_rounding(Float32,RoundToZero) do +with_rounding(Float32,RoundToZero) do @test a32 + b32 === d32 @test - a32 - b32 === -d32 @test a32 - b32 === -c32 @@ -73,7 +73,7 @@ end @test b32 - a32 == c32 # RoundUp -with_rounding(Float32,RoundUp) do +with_rounding(Float32,RoundUp) do @test a32 + b32 === 1.0f0 @test - a32 - b32 === -d32 @test a32 - b32 === -c32 @@ -81,7 +81,7 @@ with_rounding(Float32,RoundUp) do end # RoundDown -with_rounding(Float32,RoundDown) do +with_rounding(Float32,RoundDown) do @test a32 + b32 === d32 @test - a32 - b32 === -1.0f0 @test a32 - b32 === -c32 diff --git a/test/show.jl b/test/show.jl index fde527e9a750f..f567895068a41 100644 --- a/test/show.jl +++ b/test/show.jl @@ -18,7 +18,7 @@ s = "ccall(:f,Int,(Ptr{Void},),&x)" macro test_repr(x) quote - # Note: We can't just compare x1 and x2 because interpolated + # Note: We can't just compare x1 and x2 because interpolated # strings get converted to string Exprs by the first show(). # This could produce a few false positives, but until string # interpolation works we don't really have a choice. diff --git a/test/simdloop.jl b/test/simdloop.jl index 42ebfbd4235b2..bc06140bb65df 100644 --- a/test/simdloop.jl +++ b/test/simdloop.jl @@ -60,7 +60,7 @@ let j=4 # Index that is local to loop @simd for simd_loop_local=1:0 end simd_loop_local_present = true - try + try simd_loop_local += 1 catch simd_loop_local_present = false diff --git a/test/sparse.jl b/test/sparse.jl index 509986a9aff7e..afe0ac77b551a 100644 --- a/test/sparse.jl +++ b/test/sparse.jl @@ -342,7 +342,7 @@ let A = spzeros(Int, 10, 20) @test A[4:8,8:16] == 15 * ones(Int, 5, 9) end -let ASZ = 1000, TSZ = 800 +let ASZ = 1000, TSZ = 800 A = sprand(ASZ, 2*ASZ, 0.0001) B = copy(A) nA = countnz(A) diff --git a/test/suitesparse.jl b/test/suitesparse.jl index 70b28d5eccc2f..18f7405e14d99 100644 --- a/test/suitesparse.jl +++ b/test/suitesparse.jl @@ -30,7 +30,7 @@ x = lua'\b Ac = complex(A,A) lua = lufact(Ac) L,U,p,q,Rs = lua[:(:)] -@test_approx_eq scale(Rs,Ac)[p,q] L*U +@test_approx_eq scale(Rs,Ac)[p,q] L*U #4523 - complex sparse \ x = speye(2) + im * speye(2) @@ -160,6 +160,6 @@ pred = afiro'*sol @test norm(afiro * (y.mat - pred.mat)) < 1e-8 # explicit zeros -a = SparseMatrixCSC(2,2,[1,3,5],[1,2,1,2],[1.0,0.0,0.0,1.0]) +a = SparseMatrixCSC(2,2,[1,3,5],[1,2,1,2],[1.0,0.0,0.0,1.0]) @test_approx_eq lufact(a)\[2.0,3.0] [2.0,3.0] @test_approx_eq cholfact(a)\[2.0,3.0] [2.0,3.0] diff --git a/test/unicode.jl b/test/unicode.jl index 9e9648034eb02..4152800f331a0 100644 --- a/test/unicode.jl +++ b/test/unicode.jl @@ -30,7 +30,7 @@ if !success(`iconv --version`) else # Create unicode test data directory unicodedir = mktempdir() - + # Use perl to generate the primary data primary_encoding = "UTF-32BE" primary_path = replace(joinpath(unicodedir, primary_encoding*".unicode"),"\\","\\\\\\\\") @@ -40,7 +40,7 @@ else binmode(UNICODEF); print UNICODEF pack \"N*\", 0xfeff, 0..0xd7ff, 0xe000..0x10ffff; close(UNICODEF);"` ) - + # Use iconv to generate the other data for encoding in ["UTF-32LE", "UTF-16BE", "UTF-16LE", "UTF-8"] output_path = joinpath(unicodedir, encoding*".unicode") @@ -48,34 +48,34 @@ else run(`iconv -f $primary_encoding -t $encoding $primary_path` |> f) Base.FS.close(f) end - + f=open(joinpath(unicodedir,"UTF-32LE.unicode")) str1 = utf32(read(f, UInt32, 1112065)[2:end]) close(f) - + f=open(joinpath(unicodedir,"UTF-8.unicode")) str2 = UTF8String(read(f, UInt8, 4382595)[4:end]) close(f) @test str1 == str2 - + @test str1 == open(joinpath(unicodedir,"UTF-16LE.unicode")) do f utf16(read(f, UInt16, 2160641)[2:end]) end - + @test str1 == open(joinpath(unicodedir,"UTF-16LE.unicode")) do f utf16(read(f, UInt8, 2160641*2)) end @test str1 == open(joinpath(unicodedir,"UTF-16BE.unicode")) do f utf16(read(f, UInt8, 2160641*2)) end - + @test str1 == open(joinpath(unicodedir,"UTF-32LE.unicode")) do f utf32(read(f, UInt8, 1112065*4)) end @test str1 == open(joinpath(unicodedir,"UTF-32BE.unicode")) do f utf32(read(f, UInt8, 1112065*4)) end - + str1 = "∀ ε > 0, ∃ δ > 0: |x-y| < δ ⇒ |f(x)-f(y)| < ε" str2 = utf32( 8704, 32, 949, 32, 62, 32, 48, 44, 32, 8707, 32, @@ -84,7 +84,7 @@ else 41, 45, 102, 40, 121, 41, 124, 32, 60, 32, 949 ) @test str1 == str2 - + # Cleanup unicode data for encoding in ["UTF-32BE", "UTF-32LE", "UTF-16BE", "UTF-16LE", "UTF-8"] rm(joinpath(unicodedir,encoding*".unicode")) diff --git a/ui/Makefile b/ui/Makefile index d8899ed215acc..181e79fa9ad75 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -60,7 +60,7 @@ $(build_bindir)/julia$(EXE): julia_res.o $(build_bindir)/julia-debug$(EXE): julia_res.o JLDFLAGS += julia_res.o endif -endif +endif julia-release: $(build_bindir)/julia$(EXE) julia-debug: $(build_bindir)/julia-debug$(EXE)