From c171ccfe7b5a3acf198b7a14d1e5c8b6840d687a Mon Sep 17 00:00:00 2001 From: Ivar Nesje Date: Mon, 3 Mar 2014 11:21:13 +0100 Subject: [PATCH 1/7] Clarify error for openblas cross compile arch --- deps/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/Makefile b/deps/Makefile index 7a70fc10e87d0..7d2fb0b0d9aa1 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -824,7 +824,7 @@ OPENBLAS_BUILD_OPTS += BINARY=32 else ifeq ($(ARCH),x86_64) OPENBLAS_BUILD_OPTS += BINARY=64 else -$(error "unknown arch for openblas cross-compile") +$(error "unknown arch for openblas cross-compile: $(ARCH)") endif ifeq ($(OS),WINNT) From f5bf2183e531bb038177ed86bbe6dbffe95e2849 Mon Sep 17 00:00:00 2001 From: timholy Date: Mon, 3 Mar 2014 06:48:01 -0600 Subject: [PATCH 2/7] Add @nif --- base/cartesian.jl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/base/cartesian.jl b/base/cartesian.jl index 7b97c4dd8deb6..24eab26c1eaa7 100644 --- a/base/cartesian.jl +++ b/base/cartesian.jl @@ -1,6 +1,6 @@ module Cartesian -export @ngenerate, @nsplat, @nloops, @nref, @ncall, @nexprs, @nextract, @nall, @ntuple, ngenerate +export @ngenerate, @nsplat, @nloops, @nref, @ncall, @nexprs, @nextract, @nall, @ntuple, @nif, ngenerate const CARTESIAN_DIMS = 4 @@ -368,6 +368,18 @@ function _ntuple(N::Int, ex) Expr(:escape, Expr(:tuple, vars...)) end +# if condition1; operation1; elseif condition2; operation2; else operation3 +# You can pass one or two operations; the second, if present, is used in the final "else" +macro nif(N, condition, operation...) + # Handle the final "else" + ex = esc(inlineanonymous(length(operation) > 1 ? operation[2] : operation[1], N)) + # Make the nested if statements + for i = N-1:-1:1 + ex = Expr(:if, esc(inlineanonymous(condition,i)), esc(inlineanonymous(operation[1],i)), ex) + end + ex +end + ## Utilities # Simplify expressions like :(d->3:size(A,d)-3) given an explicit value for d From fb0bd5c3d1ad5ed1c2d796f26a9952482554bb82 Mon Sep 17 00:00:00 2001 From: timholy Date: Mon, 3 Mar 2014 06:48:23 -0600 Subject: [PATCH 3/7] Cartesian: improve generated expressions (evaluate more conditionals at parsing time) --- base/cartesian.jl | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/base/cartesian.jl b/base/cartesian.jl index 24eab26c1eaa7..7bbf6e52ccfca 100644 --- a/base/cartesian.jl +++ b/base/cartesian.jl @@ -395,15 +395,7 @@ function inlineanonymous(ex::Expr, val) exout = lreplace(ex, sym, val) exout = poplinenum(exout) exout = poparithmetic(exout) - # Inline ternary expressions - if isa(exout, Expr) && exout.head == :if - try - tf = eval(exout.args[1]) - exout = tf?exout.args[2]:exout.args[3] - catch - end - end - exout + popconditionals(exout) end # Given :i and 3, this generates :i_3 @@ -462,4 +454,24 @@ function poparithmetic(ex::Expr) ex end +# Resolve if/else and ternary expressions that can be evaluated at parsing time +popconditionals(arg) = arg +function popconditionals(ex::Expr) + if isa(ex, Expr) && ex.head == :if + for i = 2:length(ex.args) + ex.args[i] = popconditionals(ex.args[i]) + end + try + tf = eval(ex.args[1]) + ex = tf?ex.args[2]:ex.args[3] + catch + end + else + for i = 1:length(ex.args) + ex.args[i] = popconditionals(ex.args[i]) + end + end + ex +end + end From d36bb08f63880f9428afef5a02daf964d3c2ec40 Mon Sep 17 00:00:00 2001 From: Carlo Baldassi Date: Mon, 3 Mar 2014 18:58:06 +0100 Subject: [PATCH 4/7] Fix bug in more-than-6D SubArray indexing --- base/subarray.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/subarray.jl b/base/subarray.jl index 36848b310563a..d1c9a413d6a11 100644 --- a/base/subarray.jl +++ b/base/subarray.jl @@ -215,7 +215,7 @@ getindex(s::SubArray, i0::Real, i1::Real, i2::Real, i3::Real, i4::Real) = getindex(s::SubArray, i0::Real, i1::Real, i2::Real, i3::Real, i4::Real, i5::Real) = getindex(s, to_index(i0), to_index(i1), to_index(i2), to_index(i3), to_index(i4), to_index(i5)) getindex(s::SubArray, i0::Real, i1::Real, i2::Real, i3::Real, i4::Real, i5::Real, is::Int...) = - getindex(s, to_index(i0), to_index(i1), to_index(i2), to_index(i3), to_index(i4), to_index(5), is...) + getindex(s, to_index(i0), to_index(i1), to_index(i2), to_index(i3), to_index(i4), to_index(i5), is...) getindex(s::SubArray, i::Integer) = s[ind2sub(size(s), i)...] From e4a0d44203716836989d43a18814c4d6471fe0cc Mon Sep 17 00:00:00 2001 From: Bogdan Opanchuk Date: Tue, 4 Mar 2014 11:10:15 +1100 Subject: [PATCH 5/7] Fix typo in repackage_system_suitesparse4.make --- contrib/repackage_system_suitesparse4.make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/repackage_system_suitesparse4.make b/contrib/repackage_system_suitesparse4.make index 1d99a7ecfda8a..4b7df7274e06a 100755 --- a/contrib/repackage_system_suitesparse4.make +++ b/contrib/repackage_system_suitesparse4.make @@ -14,7 +14,7 @@ ifeq ($(USE_SYSTEM_LAPACK),0) $(build_libdir)/libgfortblas.dylib: make -C ../deps/ $(build_libdir)/libgfortblas.dylib -default: $(build_ibdir)/libgfortblas.dylib +default: $(build_libdir)/libgfortblas.dylib endif endif endif From ba91b74e231f1316aa42690c3cd5bbd6ccf92216 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Tue, 4 Mar 2014 01:32:11 -0800 Subject: [PATCH 6/7] Missing parentheses on JULIA_VERSION leads to installing to `julia-ULIA_VERSION` when `NO_GIT = 1` --- Make.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Make.inc b/Make.inc index 67fddbd12bc11..8864e5f43bed8 100644 --- a/Make.inc +++ b/Make.inc @@ -61,7 +61,7 @@ JULIA_VERSION = $(shell cat $(JULIAHOME)/VERSION) ifneq ($(NO_GIT), 1) JULIA_COMMIT = $(shell git rev-parse --short=10 HEAD) else -JULIA_COMMIT = $JULIA_VERSION +JULIA_COMMIT = $(JULIA_VERSION) endif # Directories where said libraries get installed to From 40fdf3eb6d49e30cdd3c47e1184a467cc1fc04ab Mon Sep 17 00:00:00 2001 From: timholy Date: Tue, 4 Mar 2014 05:51:26 -0600 Subject: [PATCH 7/7] Fix #6036 --- base/sparse/sparsematrix.jl | 8 ++++---- test/sparse.jl | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index 506e013b4d78b..6694d7fff5084 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -641,14 +641,14 @@ function reducedim{Tv,Ti}(f::Function, A::SparseMatrixCSC{Tv,Ti}, region, v0) end maximum{T}(A::SparseMatrixCSC{T}) = - isempty(A) ? throw(ArgumentError("argument must not be empty")) : reducedim(scalarmax,A,(1,2),typemin(T)) + isempty(A) ? throw(ArgumentError("argument must not be empty")) : reducedim(Base.scalarmax,A,(1,2),typemin(T)) maximum{T}(A::SparseMatrixCSC{T}, region) = - isempty(A) ? similar(A, reduced_dims0(A,region)) : reducedim(scalarmax,A,region,typemin(T)) + isempty(A) ? similar(A, reduced_dims0(A,region)) : reducedim(Base.scalarmax,A,region,typemin(T)) minimum{T}(A::SparseMatrixCSC{T}) = - isempty(A) ? throw(ArgumentError("argument must not be empty")) : reducedim(scalarmin,A,(1,2),typemax(T)) + isempty(A) ? throw(ArgumentError("argument must not be empty")) : reducedim(Base.scalarmin,A,(1,2),typemax(T)) minimum{T}(A::SparseMatrixCSC{T}, region) = - isempty(A) ? similar(A, reduced_dims0(A,region)) : reducedim(scalarmin,A,region,typemax(T)) + isempty(A) ? similar(A, reduced_dims0(A,region)) : reducedim(Base.scalarmin,A,region,typemax(T)) sum{T}(A::SparseMatrixCSC{T}) = reducedim(+,A,(1,2),zero(T)) sum{T}(A::SparseMatrixCSC{T}, region) = reducedim(+,A,region,zero(T)) diff --git a/test/sparse.jl b/test/sparse.jl index 4908d46e3ea8c..3b295482439d0 100644 --- a/test/sparse.jl +++ b/test/sparse.jl @@ -211,3 +211,11 @@ end # test for "access to undefined error" types that initially allocate elements as #undef @test all(sparse(1:2, 1:2, Any[1,2])^2 == sparse(1:2, 1:2, [1,4])) sd1 = diff(sparse([1,1,1], [1,2,3], Any[1,2,3]), 1) + +# issue #6036 +P = spzeros(Float64, 3, 3) +for i = 1:3 + P[i,i] = i +end +@test minimum(P) == [0] +@test maximum(P) == [3]