From eac0249f19904615105e123e06e8cfa458648642 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sat, 10 Jan 2015 13:25:58 -0500 Subject: [PATCH 1/2] rename null to nullspace --- base/deprecated.jl | 2 ++ base/exports.jl | 2 +- base/linalg/dense.jl | 4 ++-- test/linalg1.jl | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/base/deprecated.jl b/base/deprecated.jl index f2889abca63e5..28f193d2bef5c 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -268,3 +268,5 @@ const base64 = base64encode @deprecate beginswith startswith @deprecate functionlocs(f,t) map(functionloc, methods(f,t)) + +@deprecate null nullspace diff --git a/base/exports.jl b/base/exports.jl index 30211b1052805..6e626204d2b46 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -676,7 +676,7 @@ export lufact, lyap, norm, - null, + nullspace, ordschur!, ordschur, peakflops, diff --git a/base/linalg/dense.jl b/base/linalg/dense.jl index 07c6321e0ea82..2a1966753c5e4 100644 --- a/base/linalg/dense.jl +++ b/base/linalg/dense.jl @@ -455,14 +455,14 @@ pinv(a::StridedVector) = pinv(reshape(a, length(a), 1)) pinv(x::Number) = isfinite(one(x)/x) ? one(x)/x : zero(x) ## Basis for null space -function null{T}(A::StridedMatrix{T}) +function nullspace{T}(A::StridedMatrix{T}) m, n = size(A) (m == 0 || n == 0) && return eye(T, n) SVD = svdfact(A, thin=false) indstart = sum(SVD[:S] .> max(m,n)*maximum(SVD[:S])*eps(eltype(SVD[:S]))) + 1 return SVD[:V][:,indstart:end] end -null(a::StridedVector) = null(reshape(a, length(a), 1)) +nullspace(a::StridedVector) = nullspace(reshape(a, length(a), 1)) function cond(A::StridedMatrix, p::Real=2) if p == 2 diff --git a/test/linalg1.jl b/test/linalg1.jl index 9997826b32b63..56eb4865909b9 100644 --- a/test/linalg1.jl +++ b/test/linalg1.jl @@ -229,13 +229,13 @@ debug && println("Solve square general system of equations") @test_throws DimensionMismatch b\b' @test norm(a*x - b, 1)/norm(b) < ε*κ*n*2 # Ad hoc, revisit! -debug && println("Test null") +debug && println("Test nullspace") if eltya != BigFloat && eltyb != BigFloat # Revisit when implemented in julia - a15null = null(a[:,1:5]') + a15null = nullspace(a[:,1:5]') @test rank([a[:,1:5] a15null]) == 10 @test_approx_eq_eps norm(a[:,1:5]'a15null, Inf) zero(eltya) 300ε @test_approx_eq_eps norm(a15null'a[:,1:5], Inf) zero(eltya) 400ε - @test size(null(b), 2) == 0 + @test size(nullspace(b), 2) == 0 end end # for eltyb From b1a687a42929b97219c5e3133af9581ea76b56c3 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sat, 10 Jan 2015 17:18:18 -0500 Subject: [PATCH 2/2] null rename: doc/news update plus one missed rename --- NEWS.md | 2 ++ base/linalg.jl | 2 +- doc/stdlib/linalg.rst | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8dd5d51f6dec9..71f0ca9cda412 100644 --- a/NEWS.md +++ b/NEWS.md @@ -173,6 +173,8 @@ Deprecated or removed * `beginswith` is renamed to `startswith` ([#9578]). + * `null` is renamed to `nullspace`. + Julia v0.3.0 Release Notes ========================== diff --git a/base/linalg.jl b/base/linalg.jl index 4b34c00a804b9..b5afb4930f4d9 100644 --- a/base/linalg.jl +++ b/base/linalg.jl @@ -84,7 +84,7 @@ export lufact!, lyap, norm, - null, + nullspace, ordschur!, ordschur, peakflops, diff --git a/doc/stdlib/linalg.rst b/doc/stdlib/linalg.rst index 4e7e34c036112..345c02077603e 100644 --- a/doc/stdlib/linalg.rst +++ b/doc/stdlib/linalg.rst @@ -479,7 +479,7 @@ Linear algebra functions in Julia are largely implemented by calling functions f Moore-Penrose pseudoinverse -.. function:: null(M) +.. function:: nullspace(M) Basis for nullspace of ``M``.