diff --git a/base/abstractarray.jl b/base/abstractarray.jl index c92cda269fcb8..870d09b8d27f8 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -290,14 +290,14 @@ for (f,T) in ((:float16, Float16), (:float64, Float64), (:complex64, Complex64), (:complex128, Complex128)) - @eval ($f)(x::AbstractArray) = convert(AbstractArray{$T}, x) + @eval ($f){S,N}(x::AbstractArray{S,N}) = convert(AbstractArray{$T,N}, x) end float{T<:FloatingPoint}(x::AbstractArray{T}) = x complex{T<:Complex}(x::AbstractArray{T}) = x -float (x::AbstractArray) = copy!(similar(x,typeof(float(one(eltype(x))))), x) -complex (x::AbstractArray) = copy!(similar(x,typeof(complex(one(eltype(x))))), x) +float{T,N}(x::AbstractArray{T,N}) = convert(AbstractArray{typeof(float(one(T))),N},x) +complex{T,N}(x::AbstractArray{T,N}) = convert(AbstractArray{typeof(complex(one(T))),N}, x) full(x::AbstractArray) = x diff --git a/base/linalg/givens.jl b/base/linalg/givens.jl index 5766539b4420b..4da127377d26c 100644 --- a/base/linalg/givens.jl +++ b/base/linalg/givens.jl @@ -181,8 +181,18 @@ function givensAlgorithm{T<:FloatingPoint}(f::Complex{T}, g::Complex{T}) return cs, sn, r end -givens{T}(f::T, g::T, i1::Integer, i2::Integer, size::Integer) = i2 <= size ? (i1 < i2 ? Givens(size, i1, i2, convert((T,T,T), givensAlgorithm(f, g))...) : error("second index must be larger than the first")) : error("indices cannot be larger than size Givens rotation matrix") -givens{T}(A::AbstractMatrix{T}, i1::Integer, i2::Integer, col::Integer) = i1 < i2 ? Givens(size(A, 1), i1, i2, convert((T,T,T), givensAlgorithm(A[i1,col], A[i2,col]))...) : error("second row index must be larger than the first") +function givens{T}(f::T, g::T, i1::Integer, i2::Integer, size::Integer) + i2 <= size || error("indices cannot be larger than size Givens rotation matrix") + i1 < i2 || error("second index must be larger than the first") + h = givensAlgorithm(f, g) + Givens(size, i1, i2, convert(T, h[1]), convert(T, h[2]), convert(T, h[3])) +end + +function givens{T}(A::AbstractMatrix{T}, i1::Integer, i2::Integer, col::Integer) + i1 < i2 || error("second index must be larger than the first") + h = givensAlgorithm(A[i1,col], A[i2,col]) + Givens(size(A, 1), i1, i2, convert(T, h[1]), convert(T, h[2]), convert(T, h[3])) +end *{T}(G1::Givens{T}, G2::Givens{T}) = Rotation(push!(push!(Givens{T}[], G2), G1)) *(G::Givens, B::BitArray{2}) = error("method not defined") diff --git a/base/linalg/tridiag.jl b/base/linalg/tridiag.jl index 5659dab97454e..46c58a81bac7f 100644 --- a/base/linalg/tridiag.jl +++ b/base/linalg/tridiag.jl @@ -232,6 +232,7 @@ convert(::Type{Tridiagonal}, A::SymTridiagonal) = Tridiagonal(A.ev, A.dv, A.ev) -(A::SymTridiagonal, B::Tridiagonal) = Tridiagonal(A.ev-B.dl, A.dv-B.d, A.ev-B.du) convert{T}(::Type{Tridiagonal{T}},M::Tridiagonal) = Tridiagonal(convert(Vector{T}, M.dl), convert(Vector{T}, M.d), convert(Vector{T}, M.du)) +convert{T}(::Type{AbstractMatrix{T}},M::Tridiagonal) = Tridiagonal(convert(Vector{T}, M.dl), convert(Vector{T}, M.d), convert(Vector{T}, M.du)) convert{T}(::Type{Tridiagonal{T}}, M::SymTridiagonal{T}) = Tridiagonal(M) convert{T}(::Type{SymTridiagonal{T}}, M::Tridiagonal) = M.dl==M.du ? (SymTridiagonal(M.dl, M.d)) : error("Tridiagonal is not symmetric, cannot convert to SymTridiagonal") diff --git a/base/pkg/entry.jl b/base/pkg/entry.jl index 1397c97119f1a..da60aa3425599 100644 --- a/base/pkg/entry.jl +++ b/base/pkg/entry.jl @@ -663,8 +663,7 @@ function updatehook(pkgs::Vector) """) end -@windows_only const JULIA = joinpath(JULIA_HOME, ENV["JULIA_EXE"]) -@unix_only const JULIA = joinpath(JULIA_HOME, "julia-readline") +const JULIA = joinpath(JULIA_HOME, "julia-basic") function test!(pkg::String, errs::Vector{String}, notests::Vector{String}) const reqs_path = abspath(pkg,"test","REQUIRE") diff --git a/doc/manual/packages.rst b/doc/manual/packages.rst index d572efb5ab113..3fb86f2c32c3b 100644 --- a/doc/manual/packages.rst +++ b/doc/manual/packages.rst @@ -517,3 +517,17 @@ Examples:: @unix @!osx The first condition applies to any system but Windows and the second condition applies to any UNIX system besides OS X. + +Runtime checks for the current version of Julia can be made using the built-in +``VERSION`` variable, which is of type ``VersionNumber``. Such code is +occasionally necessary to keep track of new or deprecated functionality between +various releases of Julia. Examples of runtime checks:: + + VERSION < v"0.3-" #exclude all pre-release versions of 0.3 + + v"0.2-" <= VERSION < v"0.3-" #get all 0.2 versions, including pre-releases, up to the above + + v"0.2" <= VERSION < v"0.3-" #To get only stable 0.2 versions (Note v"0.2" == v"0.2.0") + + VERSION >= v"0.2.1" #get at least version 0.2.1 +