From b7f0c03e49d54a686c5f5766d84f0b2674c60aac Mon Sep 17 00:00:00 2001 From: Jim Garrison Date: Thu, 23 Apr 2015 20:44:41 -0700 Subject: [PATCH 1/4] Fix #10739, implement `isdiag` method --- base/exports.jl | 1 + base/linalg.jl | 1 + base/linalg/generic.jl | 3 +++ doc/stdlib/linalg.rst | 4 ++++ test/arrayops.jl | 11 +++++++++++ test/linalg/bidiag.jl | 4 ++-- test/linalg/triangular.jl | 6 +++++- 7 files changed, 27 insertions(+), 3 deletions(-) diff --git a/base/exports.jl b/base/exports.jl index 98d358a445aec..73d9ed60eeec2 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -634,6 +634,7 @@ export givens, hessfact!, hessfact, + isdiag, ishermitian, isposdef!, isposdef, diff --git a/base/linalg.jl b/base/linalg.jl index 54c9ca18c10f6..69b370a61a234 100644 --- a/base/linalg.jl +++ b/base/linalg.jl @@ -69,6 +69,7 @@ export gradient, hessfact, hessfact!, + isdiag, ishermitian, isposdef, isposdef!, diff --git a/base/linalg/generic.jl b/base/linalg/generic.jl index cf8ab0ecd9c24..31b09a13d7749 100644 --- a/base/linalg/generic.jl +++ b/base/linalg/generic.jl @@ -308,8 +308,11 @@ function istril(A::AbstractMatrix) return true end +isdiag(A::AbstractMatrix) = istril(A) && istriu(A) + istriu(x::Number) = true istril(x::Number) = true +isdiag(x::Number) = true linreg{T<:Number}(X::StridedVecOrMat{T}, y::Vector{T}) = [ones(T, size(X,1)) X] \ y diff --git a/doc/stdlib/linalg.rst b/doc/stdlib/linalg.rst index 667b049048232..4a981534c233f 100644 --- a/doc/stdlib/linalg.rst +++ b/doc/stdlib/linalg.rst @@ -630,6 +630,10 @@ Linear algebra functions in Julia are largely implemented by calling functions f Test whether a matrix is upper triangular. +.. function:: isdiag(A) -> Bool + + Test whether a matrix is diagonal. + .. function:: ishermitian(A) -> Bool Test whether a matrix is Hermitian. diff --git a/test/arrayops.jl b/test/arrayops.jl index 3beab3105d8cd..e6a9dfce6ed93 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -806,6 +806,17 @@ end @test_throws ArgumentError flipdim(1:10, -1) @test isequal(flipdim(Array(Int,0,0),1), Array(Int,0,0)) # issue #5872 +# isdiag, istril, istriu +@test isdiag(3) +@test istril(4) +@test istriu(5) +@test !isdiag([1 2; 3 4]) +@test !istril([1 2; 3 4]) +@test !istriu([1 2; 3 4]) +@test isdiag([1 0; 0 4]) +@test istril([1 0; 3 4]) +@test istriu([1 2; 0 4]) + # issue 4228 A = [[i i; i i] for i=1:2] @test cumsum(A) == Any[[1 1; 1 1], [3 3; 3 3]] diff --git a/test/linalg/bidiag.jl b/test/linalg/bidiag.jl index d1854805a9310..57e884c350481 100644 --- a/test/linalg/bidiag.jl +++ b/test/linalg/bidiag.jl @@ -78,8 +78,8 @@ for relty in (Float32, Float64, BigFloat), elty in (relty, Complex{relty}) end end -#Issue 10742 +# Issue 10742 and similar let A = Bidiagonal([1,2,3], [0,0], true) @test istril(A) + @test isdiag(A) end - diff --git a/test/linalg/triangular.jl b/test/linalg/triangular.jl index cd5fffdaf5cc6..5ead78671e276 100644 --- a/test/linalg/triangular.jl +++ b/test/linalg/triangular.jl @@ -275,6 +275,10 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) end end -# Issue 10742 +# Issue 10742 and similar @test istril(UpperTriangular(diagm([1,2,3,4]))) @test istriu(LowerTriangular(diagm([1,2,3,4]))) +@test isdiag(UpperTriangular(diagm([1,2,3,4]))) +@test isdiag(LowerTriangular(diagm([1,2,3,4]))) +@test !isdiag(UpperTriangular(rand(4, 4))) +@test !isdiag(LowerTriangular(rand(4, 4))) From 5ef94fa37363fa37ba8385b79fa38ffe304ab644 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Sun, 26 Apr 2015 07:37:13 -0700 Subject: [PATCH 2/4] Fix @windowsxp_only macro the previous version of this macro was hard-coding the result of windows_version() from the build machine, and the buildbots are all newer than XP so this was not working correctly --- base/osutils.jl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/base/osutils.jl b/base/osutils.jl index c58115719a0a8..764c8a44556e6 100644 --- a/base/osutils.jl +++ b/base/osutils.jl @@ -55,14 +55,10 @@ end WINDOWS_XP_VER = (5,1) -macro windowsxp(qm,ex) - _os_test(qm, ex, OS_NAME===:Windows && windows_version() <= WINDOWS_XP_VER) -end - macro windowsxp_only(ex) - @windowsxp? esc(ex) : nothing + _os_test(:?, Expr(:(:), ex, nothing), OS_NAME===:Windows && windows_version() <= WINDOWS_XP_VER) end macro non_windowsxp_only(ex) - @windowsxp? nothing : esc(ex) + _os_test(:?, Expr(:(:), nothing, ex), OS_NAME===:Windows && windows_version() <= WINDOWS_XP_VER) end From 6a58b9711736a60be0433c5491c2975eb8ae0620 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Sun, 26 Apr 2015 07:38:44 -0700 Subject: [PATCH 3/4] Don't run a few tests which fail on XP repl tests freeze otherwise, the fix in libuv for #7082 does not work on XP dllist tests also fail on xp since oddly Libdl.dllist() is only listing file names, not full absolute paths udp recvfrom tests give ERROR: LoadError: bind: address family not supported (EAFNOSUPPORT) --- test/backtrace.jl | 4 ++-- test/repl.jl | 4 ++-- test/socket.jl | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/backtrace.jl b/test/backtrace.jl index bef07cf1e3ecf..6ed5e1e47e118 100644 --- a/test/backtrace.jl +++ b/test/backtrace.jl @@ -16,8 +16,8 @@ end dlls = Libdl.dllist() @test !isempty(dlls) @test length(dlls) > 3 # at a bare minimum, probably have some version of libstdc, libgcc, libjulia, ... -@test Base.samefile(Libdl.dlpath(dlls[1]), dlls[1]) -@test Base.samefile(Libdl.dlpath(dlls[end]), dlls[end]) +@non_windowsxp_only @test Base.samefile(Libdl.dlpath(dlls[1]), dlls[1]) +@non_windowsxp_only @test Base.samefile(Libdl.dlpath(dlls[end]), dlls[end]) @test length(filter(dlls) do dl return ismatch(Regex("^libjulia(?:.*)\.$(Libdl.dlext)(?:\..+)?\$"), basename(dl)) end) == 1 # look for something libjulia-like (but only one) diff --git a/test/repl.jl b/test/repl.jl index 059415fdf8591..5ba49f3b92f85 100644 --- a/test/repl.jl +++ b/test/repl.jl @@ -25,7 +25,7 @@ ccall(:jl_exit_on_sigint, Void, (Cint,), 0) # in the mix. If verification needs to be done, keep it to the bare minimum. Basically # this should make sure nothing crashes without depending on how exactly the control # characters are being used. -begin +@non_windowsxp_only begin stdin_write, stdout_read, stdout_read, repl = fake_repl() repl.specialdisplay = Base.REPL.REPLDisplay(repl) @@ -235,7 +235,7 @@ end ccall(:jl_exit_on_sigint, Void, (Cint,), 1) -let exename = joinpath(JULIA_HOME, Base.julia_exename()) +@non_windowsxp_only let exename = joinpath(JULIA_HOME, Base.julia_exename()) # Test REPL in dumb mode @unix_only begin diff --git a/test/socket.jl b/test/socket.jl index c10772f1933b3..ebbf17308f6e5 100644 --- a/test/socket.jl +++ b/test/socket.jl @@ -159,7 +159,7 @@ begin close(a) close(b) end -begin +@non_windowsxp_only begin a = UDPSocket() b = UDPSocket() bind(a, ip"::1", UInt16(port)) From 719089656dedfefa4be1925c00a3f2c323f8d2bd Mon Sep 17 00:00:00 2001 From: Seth Bromberger Date: Fri, 24 Apr 2015 06:38:27 -0700 Subject: [PATCH 4/4] Provide RPi2 build instructions per request Per https://github.com/JuliaLang/julia/issues/10235#issuecomment-95810770, provide build instructions for Raspberry Pi 2. Update README.arm.md --- README.arm.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.arm.md b/README.arm.md index 015a4f95eb4d5..c17645f4db225 100644 --- a/README.arm.md +++ b/README.arm.md @@ -42,3 +42,38 @@ Crouton, you can do so by following these tutorials. # Building LLVM on ARM - If you run in to issues building LLVM, see these notes: [http://llvm.org/docs/HowToBuildOnARM.html](http://llvm.org/docs/HowToBuildOnARM.html) + +# For the Raspberry Pi version 2 (RPi2) + +Success in building Julia has been reported using the following procedure: + +1. Follow the steps above to install the `build-essentals` and other packages required for ARM +2. Install FFTW and libedit using `sudo apt-get install libfftw3-3 libedit-dev` +3. Download the [LLVM 3.6.0 binaries for ARMv7a] (http://llvm.org/releases/3.6.0/clang+llvm-3.6.0-armv7a-linux-gnueabihf.tar.xz) and extract them in a local directory. +4. For each file in the extracted `bin`, `include`, and `lib` subdirectories, create symlinks from the corresponding directory under `/usr/local`. +5. Using the `Make.arm` configuration below, build Julia using `make -j 2`. (Limiting `make` to 2 simultaneous jobs will reduce the possibility of running out of memory/swap space during the build process.) + +Note that the resulting Julia binary may fail various tests but will run code and provide the REPL. + +`Make.arm` for RPi2: + +``` +override LLVM_ASSERTIONS=1 +LLVM_FLAGS+="--with-cpu=cortex-a9 --with-float=hard --with-abi=aapcs-vfp --with-fpu=neon --enable-targets=arm --enable-optimized --enable-assertions" + +override OPENBLAS_DYNAMIC_ARCH=0 +override OPENBLAS_TARGET_ARCH=ARMV7 +override USE_BLAS64=0 + +override USE_SYSTEM_LIBM=1 +override USE_SYSTEM_FFTW=1 +override USE_SYSTEM_GMP=1 +override USE_SYSTEM_MPFR=1 +override USE_SYSTEM_LAPACK=1 + +JCFLAGS += -fsigned-char + +override USE_SYSTEM_LLVM=1 +override USE_SYSTEM_BLAS=1 +``` +